您的位置:首页 > 其它

gps打开接口

2015-03-27 11:31 85 查看
android判断gps是否打开的接口:

public boolean isGpsOpen(Context context) {
return Settings.Secure.isLocationProviderEnabled(context.getContentResolver(),
android.location.LocationManager.GPS_PROVIDER);
}


android中打开gps的接口:

同时需要<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>权限

public static void enableGps(Context context, boolean enable) {

try {
Settings.Secure.setLocationProviderEnabled(context.getContentResolver(), LocationManager.GPS_PROVIDER,
enable);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: