GUIなしでバックグラウンドで実行できるBroadcastReceiver
Androidの他のコンポーネントを使用します。Service
public class UploadData extends BroadcastReceiver
{
private static LocationManager locationManager = null;
private static LocationListener locationListener = null;
@Override
public void onReceive(Context context, Intent intent)
{
// Create and AlarmManager that will periodically fetch the GPS
}
}
サービスの場合、
public class myservice extends Service
{
LocationManager locationManager = null;
LocationListener loclistener = null;
// Bind it, Its important
public IBinder onBind(Intent intent)
{
return null;
}
@Override
public void onCreate()
{
// Use AlarmManager to fetch the GPS periodically.
}
}