我有一个检查网络连接状态的项目如下:
public void GetStatus ()
{
ConnectivityManager oManager;
ConnectivityState eState;
//
oManager = (ConnectivityManager)m_oContext.GetSystemService (Activity.ConnectivityService);
//
if (oManager.ActiveNetworkInfo == null)
Connected = false;
else
Connected = oManager.ActiveNetworkInfo.IsConnected;
//
// Get the current connection state
if (!Connected)
eState = ConnectivityState.NotConnected;
else if (oManager.GetNetworkInfo (ConnectivityType.Mobile).GetState () == NetworkInfo.State.Connected)
eState = ConnectivityState.Roaming;
else if (oManager.GetNetworkInfo (ConnectivityType.Wifi).GetState () == NetworkInfo.State.Connected)
eState = ConnectivityState.WiFi;
else
eState = ConnectivityState.Other;
//
State = eState;
//
if (StatusUpdated != null)
StatusUpdated ();
}
从Xamarin Studio运行时,此工作正常,但现在我已将项目移至Visual Studio 2012,但它没有获取清单中的权限集。这是我在清单中的内容:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="MyApp.Android">
<uses-sdk android:targetSdkVersion="10" android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="My App"></application>
</manifest>
我通过转到解决方案的属性并选择从那里创建它来创建清单文件,然后检查ACCESS_NETWORK_STATE
的复选框,但是当我从VS2012运行时,我得到一个例外,说设备没有'得到许可。对此有何帮助?感谢。