これは基本的にBroadcastReceiver
からの単一の更新をリッスンし始めたいのですが、何らかの理由ですべてのプロバイダが自分のアクセスから無効になっています。ここでは、コードスニペットはLocationManager getProviders(true)プロバイダが返されない
LocationManager locationManager = (LocationManager)
context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setPowerRequirement(Criteria.POWER_LOW);
String majorProvider = locationManager.getBestProvider(criteria, true);
Log.d("location test", "major provider " + majorProvider);
List<String> allProviders = locationManager.getAllProviders();
for(int i=0; i < allProviders.size();i++) {
Log.d("location test", "provider " + i + ": " + allProviders.get(i));
}
Log.d("location test", "enabled...");
allProviders = locationManager.getProviders(true);
for(int i=0; i < allProviders.size();i++) {
Log.d("location test", "enabled provider " + i + ": " + allProviders.get(i));
}
で、私のlogcatは
04-09 11:23:35.763: D/location test(32576): major provider null
04-09 11:23:35.763: D/location test(32576): provider 0: network
04-09 11:23:35.763: D/location test(32576): provider 1: passive
04-09 11:23:35.763: D/location test(32576): provider 2: gps
04-09 11:23:35.763: D/location test(32576): enabled...
結果、私はこの問題は私がBroadcastReceiver
からこのすべてを呼び出していますということであると推測していますが、私はどこか別の場所からそれをコンテキストを渡してみました。 BroadcastReceiver
からLocationManagerにアクセスできませんか?
すべてのプロバイダが有効になっているかどうか... – ngesh
@sandy彼らはすべて無効になっていた、それは単に忘れられた許可だった – MikeIsrael