我正在使用Xamarin.Android,并编写了以下代码:
public TextView text;
text = FindViewById<TextView>(Resource.Id.viewIP);
foreach (IPAddress adress in Dns.GetHostAddresses(Dns.GetHostName()))
{
text.Text = "IP Adress: " + adress;
}
然而,当我打开应用程序时,它立即关闭。我获取设备IP地址的方式正确吗?