新しい FusedLocationService を使用していますが、屋内にいるときに緯度と経度を取得しているにもかかわらず、GPS 信号が取得されていません (通知バーに小さな GPS ポイントが表示されません)。
位置情報サービスに適応したhereの例を使用しています
私が理解していないのは、GPSが有効になっているにもかかわらずGPS信号が検索されない理由です(ただし、座標を取得していますが、wifiまたはセルIDから取得していると思います)
私の Application クラスでは、Service を作成します (これは ServicesManager であり、別のサービスを (場所を取得するために) 作成します)。コンテキストとして ServicesManager を LocationClient に送信しています (サービスであるため)。
前もって感謝します。ギレルモ。
更新 GPS が有効になっているときに電話の位置情報サービスで [ワイヤレス ネットワークを使用] オプションをオフにすると、位置情報がまったく取得されません。そのため、FusedLocationService と GPS で何かが起こっています。
より理解できるようにコードを追加します
Applicationクラスでは、次の LocalService の例を使用しています。
private ServicesManager mBoundService;
    private boolean mIsBound;
    private ServiceConnection mConnectionToServicesManager = new ServiceConnection() {
        public void onServiceConnected(ComponentName className, IBinder service) {
            mBoundService = ((ServicesManager.LocalBinder)service).getService();
    servicesManager = mBoundService;
        }
        public void onServiceDisconnected(ComponentName className) {
            mBoundService = null;
        }
    };
    void doBindServiceManagerService() {
        bindService(new Intent(this, ServicesManager.class), mConnectionToServicesManager, Context.BIND_AUTO_CREATE);
        mIsBound = true;
    }
    void doUnbindService() {
        if (mIsBound) {
            unbindService(mConnectionToServicesManager);
            mIsBound = false;
        }
    }
次に、ServicesManagerが Service を拡張し、コンストラクターで次のように記述します。
fusedLocationService = new FusedLocationService(this);
次に、次のように呼び出します。
fusedLocationService.startListeningLocationUpdates(this);
これは FusedLocationService クラスのstartListeningLocationUpdatesの実装です
public boolean startListeningLocationUpdates(Context context) {
    if (!GdpTesisApplication.IsGooglePlayServicesAvailable) {
        return false;
    }
    mDetectionRequester.requestUpdates();
    FusedLocationService.IsServiceRunning  = true;
    return true;
}
そして requestUpdates() は GooglePlayServices への接続を試みます
private void requestConnection() {
    getFusedLocationClient().connect();
}
@Override
public void onConnected(Bundle arg0) {
    continueRequestLocationUpdates();
}
private void continueRequestLocationUpdates() {
    locationrequest = LocationRequest.create();
    locationrequest.setInterval(LocationUtils.DETECTION_INTERVAL_MILLISECONDS);
    getFusedLocationClient().requestLocationUpdates(locationrequest, createRequestPendingIntent());
}
private PendingIntent createRequestPendingIntent() {
    if (null != getRequestPendingIntent()) {
        return mFusedLocationPendingIntent;
    } else {
        Intent intent = new Intent(mContext, FusedLocationIntentService.class);
        PendingIntent pendingIntent = PendingIntent.getService(mContext, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        setRequestPendingIntent(pendingIntent);
        return pendingIntent;
    }
}
最後に、onHandleIntent が場所を抽出して表示する IntentService があります。
Location location = intent.getParcelableExtra(LocationClient.KEY_LOCATION_CHANGED);
GPSが機能しない理由がわかりません。何か案が?