タイマーでアクションを実行するサービスがあります。サービスはアクティビティから実行されます。アプリケーションの実行中、サービスは正常に動作します。ランチャーのクリーンアップを使用してアプリケーションを閉じると、サービスは再起動モードになりますが、再起動しません。これは正常ですか?
サービス:
public class MyService extends Service
{
private static Timer timer = new Timer();
public void onCreate()
{
super.onCreate();
}
private void startService()
{
timer.scheduleAtFixedRate(new mainTask(), 0, 10000);
}
private class mainTask extends TimerTask
{
public void run()
{
//MY CODE
}
}
public int onStartCommand(Intent intent, int flags, int startId)
{
startService();
return START_STICKY;
}
public void onDestroy()
{
super.onDestroy();
}
public IBinder onBind(Intent intent)
{
return null;
}
}