从IntentService类中调用Activity的问题
问题描述:
在我的应用程序中,我使用IntentService
类在后台启动另一个活动。但我得到的问题是,假设我从IntentService
课开始了我的活动,开启了我的活动,之后我不关闭活动。然后我注意到,当IntentService
类再次想要开始我的同一活动时,它不会被调用,因为同一活动不会关闭。所以我的问题是我怎样才能从IntentService
课程开始或关闭一次又一次地开始相同的活动。从IntentService类中调用Activity的问题
守则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));
}
}
答
清单文件使用launchMode标签
<activity
android:name=".ActivityName"
android:launchMode="singleTask" />
也不会,如果已有创建活动的不同实例..
看到这链接launchMode以便更好地了解
它的工作......谢谢你的回复 – AndroidDev 2012-07-07 07:16:48
可以帮助我解决这个问题http://stackoverflow.com/questions/11373130/how-to-get-foldername-and-filename-from-the-directorypath – AndroidDev 2012-07-07 07:26:13