2012-07-07 3 views
3

내 앱에서 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)); 
    }  
} 

답변

6

사용 launchMode 태그

<activity 
     android:name=".ActivityName" 

     android:launchMode="singleTask" /> 

그것은

이 볼 .. 활동의 다른 인스턴스를 생성하지 않습니다 더 나은 이해를 위해 launchMode 링크

+0

예치가 작동 중 ... 답장을 주셔서 감사합니다 – AndroidDev

+0

이 질문을 해결하는 데 도움을 줄 수 있습니까? http://stackoverflow.com/questions/11373130/how-to-get-foldername-and-filename-from-the-directorypath – AndroidDev

관련 문제