Service
및 AlarmManager
이 필요합니다. 귀하의 서비스는 직책을 얻고이를 서버에 게시하고 귀하가 결정한 기간에 AlarmManager
이 귀하의 서비스를 시작합니다. 당신은 onCreate
에 약이처럼 Service
로 알람 관리기를 초기화해야 또는 다른 장소 당신이 원하는 :
AlarmManager alarmMgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, YourAlarmReceiver.class),PendingIntent.FLAG_CANCEL_CURRENT);
// Use inexact repeating which is easier on battery (system can phase events and not wake at exact times)
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, YOUR_ALARM_TRIGGER_AT_TIME,YOUR_ALARM_INTERVAL, pendingIntent);
YourAlarmReceiver 거 서비스를 사용하는 방법에 대한
public class YourAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, YourService.class));
}
}
는 안드로이드 웹 사이트를 참조하여 서비스를 시작
http://developer.android.com/guide/topics/fundamentals/services.html
잘 풀리면 나는 이것을 시험해보고 여기에 올릴 것입니다. 고맙습니다. – Sap
나는 그것을 시험해 보았고 그 목적은 잘되었다. 지금 내가 겪고있는 문제는 너무 많은 데이터 요소를 얻고 있다는 것입니다. * LocationManager *에게 최소 10 미터의 위치가 보일 때만 [작업] 할 것을 요청합니다. 여전히 변위가 나타날 때까지 동일한 위치의 두 번째 (거의) 데이터 포인트를 얻고 있습니다. * AlarmManager * 때문일 수 있습니까? – Sap
AlarmManager를 사용하여 LocationManager를 호출하고 있습니까? AlarmManager에 지정한 간격은 해당 간격으로 원하는 서비스를 호출하는 데 사용됩니다 ... 문제를 정확히 이해할 수 없습니까? 당신은 당신이 너무 많은 업데이 트를 가지고 있다면, 간격을 늘릴 수있다. 만약 therese가 10 미터 변위가 있다면 당신은 결과를 처분 할 수 있고, 그러나 10 미터의 변위가있는 것 같지 않다면 alarmmanager로 결과를 얻은 후에 GPS 정확도가 충분하지 않습니다. –