私はサービスからの所在地を取得しようとしていますが、nullが返されていますが、何が問題か分かりません。ここで私のサンプルコードは以下のとおりです。android locationlistener
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
locListener = new GpsLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0,
locListener);
loc = locListener.getLocation();
showMessage("Service started");
if (loc != null) {
latitude = String.valueOf(loc.getLatitude());
longitude = String.valueOf(loc.getLongitude());
}
if (latitude != null && longitude != null) {
connectWebservice();
}
Log.i("trackmeservice", "service started");
}
ここで私のlocはnullです。どんな助けでも感謝します。
上マニフェストファイルへのアクセス権を追加GpsLocationListenerは何ですか?それはあなたのクラスですか? – MikeIsrael
GpsLocationListenerはLocationListenerを実装する私のクラスです – user1138300