我尝试上传关闭 GPS 并启用“平面模式”的应用程序,但由于导致Galaxy Tab Wi-Fi(M180W)的错误而被拒绝。所以我需要一些帮助来确定设备是否具有平面模式功能或 GPS。
全球定位系统:
//gps
final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
appPrefs.setGPS(manager.isProviderEnabled( LocationManager.GPS_PROVIDER));
if (manager.isProviderEnabled( LocationManager.GPS_PROVIDER) && manager!=null){
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
startActivity(myIntent);
Toast toast = Toast.makeText(getApplicationContext(), "Please turn off GPS and hit back", Toast.LENGTH_LONG);
toast.show();
平面模式:
// plane mode
if (option){
appPrefs.setCBoption(true);
// read the airplane mode setting
boolean isEnabled = Settings.System.getInt(
getApplicationContext().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) == 1;
// toggle airplane mode
Settings.System.putInt(
getApplicationContext().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
// Post an intent to reload
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);