Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
getBaseContext().sendBroadcast(intent);`
我使用此代碼來啓用GPS,但它給我這樣的錯誤。如何在Android 4.4中以編程方式啓用/禁用GPS?
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.location.GPS_ENABLED_CHANGE from pid=1208, uid=10051
所以,任何人給我的解決方案。
您不能以編程方式啓用的Android /禁用GPS。您可以要求用戶啓用/禁用它。 – Naddy