在Android上,我檢查位置與android marshmallow:如何知道用戶是否拒絕一個應用程序的權限?
LocationManager.isProviderEnabled(GPS_PROVIDER) || LocationManager.isProviderEnabled(NETWORK_PROVIDER)
這項工作很好用,但是在棉花糖(和上),當用戶在應用設置中去,只有拒絕我的應用程序的權限使用位置(只爲我的應用程序,像mashmallow現在允許這樣做),那麼以前的請求仍然返回true
我嘗試也:
MyActivity.checkSelfPermission('android.permission.ACCESS_FINE_LOCATION') == PERMISSION_GRANTED or MyActivity.checkSelfPermission('android.permission.ACCESS_COARSE_LOCATION') == PERMISSION_GRANTED
但是,即使用戶拒絕許可t將其總是返回true o我的應用程序
你的targetSdkVersion設置爲? – Michael
到14(我現在不能增加它),但通常它不是不重要?因爲checkSelfPermission只是在api 23上引入的,所以如果targetSdkVersion <23 ...我認爲它們的行爲不同是沒有道理的! – loki