私は Android 携帯電話を使用して屋外で位置を特定し、屋内に戻りましたが、GPS 信号はありません。ここで場所の結果を返す呼び出しgetLastKnownLocation()
は前回のものです。実際のところ、(屋内) には GPS 信号がありません。GPS の状態を更新するにはどうすればよいですか?
1325 次
3 に答える
0
屋内でテストしている場合は、ネットワークとgps衛星の両方を使用してみてください(注:ネットワークからの位置情報が100%正確でない場合があります)
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
そして、gps-reciverからgps修正を取得するまでしばらく待ちます。通常、信号強度が低い場合は2〜3分かかり、時間がかかる場合があります。
問題が発生した場合は、コードを入力してください。確認します
于 2012-12-11T03:52:37.510 に答える
0
必要に応じて、5 分ごとにサービスを開始できます。pending Intent
long UPDATE_INTERVAL=300000;
Intent myIntent=new Intent(Main.this,YourGPSLOcationClass.class);
PendingIntent pendingIntent=PendingIntent.getService(Main.this,0,myIntent,0);
AlarmManager alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MINUTE,0);
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),UPDATE_INTERVAL,pendingIntent);
于 2012-12-11T04:48:58.347 に答える