我想点击对话框中的是按钮,在后台自动打开 GPS 位置启用。怎么可能?
Intent callGPSSettingIntent = new Intent(
// android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
// ChatSDK.getSDKInstance().activity
// .startActivity(callGPSSettingIntent);
String provider = Settings.Secure.getString(ChatSDK.getSDKInstance().activity.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider.contains("gps")){ // for turn on
final Intent poke = new Intent();
System.out.println("innnnnnnnnn");
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
ChatSDK.getSDKInstance().activity.sendBroadcast(poke);
Toast.makeText(ChatSDK.getSDKInstance().activity, "Your GPS is Enabled",Toast.LENGTH_SHORT).show();
}
}