LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
//若GPS未打开,跳转到GPS设置页面
if (!(locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER))){
//下面括号内的字符串也可以改为“gps”
startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"));
}
本人发布的内容均为学习中用过的代码,上传主要为了方便以后的复习和为他人提供一些方便,一些代码没有上下文,新学的朋友有不懂或存在问题的地方可以留言。