2011-04-24 10 views

답변

1

상태 표시 줄 알림 작성에 대한 설명서를 검토하십시오. 이것은 Intent와 PendingIntent를 사용하여 Notification의 시작과 Activity를 확실히 다루고 있습니다.

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

활동이 이미 실행중인 경우, 그것은을 마치고 갓을 시작으로 ... 난 그게 당신이 정말로 원하는 내용에 따라 쉽게 수행 할 수 있습니다 모르겠어요.

http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

그리고 (() 가장 가능성이 onNewIntent로) 활동의 응답을 가지고 있고 프로그램 자체를 "다시"당신은 매니페스트에서 발사 모드 작동 매개 변수를 사용하여 뭔가를 할 수 있습니다. 아마도이 같은 뭔가 :

Android restart my activity

1

당신은 활동를 다시 시작하는 의미? 가장 일반적인 접근법은 동일한 클래스로 새로운 인 텐트를 다시 시작하는 것일뿐입니다. 너무 많은 메모리를 사용한다고 생각합니다. 오히려 onCreate에서 호출해야하는 "init"메소드를 작성하고 활동을 다시 시작하려고합니다. 예 :

public void onCreate(Bundle si){ 
    // Call super and set your layout... 
    init(); 
} 

/** 
* This method should be called whenever you want to restart your activity. The 
* biggest advantage is you already have your layout (setContentView() method) 
*/ 
private void relaunchActivityA(){ 
    // Clean or save anything you need to clean or save 
    init(); 
} 

private void init(){ 
    // Init your variables, threads, and so on 
} 

당신이 쓴 경우 A- 대신 '활동 B'다음 직후에 당신의 startActivity를() -on 활동 '이 신선한 시작 활동 A를 완료', '마감'부른다. 예 :

// This is inside Activity A 
Intent i = new Intent(this, ActivityB.class); 
startActivity(); 
finish(); // This will be called right after 'Activity B' finishes 
+0

활동 B를 사용하여 수행 할 수 있지만 알림에서 활동 A를 시작합니다. – Android