1
GPSのオン/オフを決定できません。isProviderEnabledは常に「false」ですが、GPSはオンになっています。なぜGPS_PROVIDER isProviderEnabledのチェックが常に「偽」ですか?
public abstract class BaseGPSActivity extends AppCompatActivity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Log.v(TAG, " GPS is enabled: "+isGPSEnabled()))
public boolean isGPSEnabled(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider != null)
Log.v(TAG, " Location providers: "+provider);
return mLocationManager!=null && mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
出力は次のようになりますので、デバイスの設定で "高精度" をチェックする必要がありました
V/BaseGPSActivity: Location providers: network
V/BaseGPSActivity: GPS is enabled: false
試すhttp://stackoverflow.com/a/7990939/5305430 – sushildlh