Click here to Skip to main content
15,892,746 members
Articles / Web Development / HTML

Zyan Drench, A Game for Android with Wifi Support

Rate me:
Please Sign up or sign in to vote.
4.99/5 (17 votes)
28 Feb 2016MIT12 min read 47.3K   1.3K   37  
This article describes building an Android game with networking support using C#, Xamarin.Android platform and Zyan Communication Framework.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Webkit;

namespace Drench
{
	[Activity (Label = "Zyan Drench")]
	public class HelpActivity : Activity
	{
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			RequestWindowFeature(WindowFeatures.CustomTitle);
			var webview = new WebView(this);
			webview.SetBackgroundColor(Settings.DisabledColor);
			SetContentView(webview);

			// Set custom title
			Window.SetFeatureInt(WindowFeatures.CustomTitle, Resource.Layout.CustomTitle);
			var title = FindViewById<RelativeLayout>(Resource.Id.titleLayout);
			var parentView = title.Parent as View;
			if (parentView != null)
			{
				// the following line generates strange artifacts sometimes:
				parentView.SetBackgroundColor(Settings.CustomTitleColor);
				title.SetBackgroundColor(Settings.CustomTitleColor);
			}

			// Load and display help page 
			using (var helpAsset = Assets.Open("Help.html"))
			using (var reader = new StreamReader(helpAsset))
			{
				var text = reader.ReadToEnd();
				webview.LoadDataWithBaseURL("file:///android_asset/", text, "text/html", "utf-8", null);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) ULTIMA Businessware
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions