0
我試圖讓我的GPS在一個服務工作,但它不工作。 GPS位自身工作,但不在服務中。Android GPS不能在服務
我曾嘗試用System.out.println()進行調試,並且喜歡它停止工作的位置,但無法找出爲什麼它看起來不錯。
public int onStartCommand(Intent intent, int flags, int startId) {
System.out.println("test 1");
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
System.out.println("test 2");
LocationListener lli = new myLocationListener();
System.out.println("test 3");
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, lli);
System.out.println("test 4");
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
class myLocationListener implements LocationListener{
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
if(location != null){
pet.setMeter();
}
}
它進入測試4,然後死亡。我迷失在爲什麼如果任何人都可以幫助這將是非常感謝。
確實,當我到達計算機時會這樣做 – cYrixmorten