Dix*_*ine 5 java android location
当我检查
boolean networkReady=manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Run Code Online (Sandbox Code Playgroud)
虽然在设置中不允许使用无线位置,但我会在某些三星手机上使用.
有没有其他方法可以检查此设置并在所有手机上获得正确的值?
在我的应用程序中使用的一些不错的网络工具函数下面,所有的工作就像一个魅力!和位置轮询,绝对 - > https://github.com/commonsguy/cwac-locpoll
希望这可以帮助...
public static boolean checkInternetConnection(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
// ARE WE CONNECTED TO THE NET?
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
return true;
} else {
Log.w(TAG, "Internet Connection NOT Present");
return false;
}
}
public static boolean isConnAvailAndNotRoaming(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
if(!conMgr.getActiveNetworkInfo().isRoaming())
return true;
else
return false;
} else {
Log.w(TAG, "Internet Connection NOT Present");
return false;
}
}
public static boolean isRoaming(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
return (conMgr.getActiveNetworkInfo()!=null && conMgr.getActiveNetworkInfo().isRoaming());
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1236 次 |
最近记录: |