Hi everybody I have some problem. Before now I can run this code but this time I can't when I run the application is shut down. Someone can test this code for me if you can I will check my phone. Thank you for help my.
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
namespace top
{
[Activity (Label = "top", MainLauncher = true)]
public class MainActivity : Activity
{
int count = 1;
public TextView _tv;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
_tv = FindViewById<TextView>(Resource.Id.txtIP);
_tv.Text = "YOUR IP :" + GetLocalIP ();
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.myButton);
button.Click += delegate {
button.Text = string.Format ("{0} clicks!", count++);
};
}
private string GetLocalIP()
{
IPHostEntry host;
host = Dns.GetHostEntry (Dns.GetHostName ());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
return ip.ToString ();
}
return "127.0.0.1";
}
}
}