好吧,我找到了一种方法来检查“ Location
”设置action bar
是启用还是禁用;但没有(BroadcastReceiver
真遗憾)
private static final String TAG = getClass().getName();
/* We define the LocationManager */
LocationManager location_Manager= (LocationManager) getSystemService(LOCATION_SERVICE);
/* If the GPS provider or the network provider are enabled; the Location setting is enabled.*/
if(location_Manager.isProviderEnabled(LocationManager.GPS_PROVIDER) || location_Manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
Log.d(TAG, "The Location setting is enabled");
}else{
/* We send the user to the "Location activity" to enable the setting */
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
我真的不需要BroadcastReceiver
; 因为拥有我的应用程序的“架构”允许我没有它;但我很想知道如何使用它。
注意:
如果有人找到解决方法,BroadcastReceiver
我会用她的答案更改我的正确答案。