私のアプリでは、IntentService
クラスを使用してバックグラウンドで別のアクティビティを開始しています。しかし、私が得た問題は、IntentService
クラスからアクティビティを開始すると、アクティビティが開き、その後アクティビティを閉じないとします。IntentService
次に、クラスが再び同じアクティビティを開始したいときに、同じアクティビティが閉じていないため呼び出されないことに気付きました。
IntentService
それで、私の質問は、クラスから開いているか閉じているかに関係なく、同じアクティビティを何度も開始するにはどうすればよいですか?
IntentService クラスのコード
public class AlarmService extends IntentService
{
public void onCreate() {
super.onCreate();
}
public AlarmService() {
super("MyAlarmService");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, startId, startId);
return START_STICKY;
}
@Override
protected void onHandleIntent(Intent intent) {
startActivity(new Intent(this,
AlarmDialogActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}