Ich erstelle Benachrichtigungen von einem Dienst. Diese Mitteilung enthält eine Absicht, dass A Aktivität erzeugen:Aktivität ausgelöst, wenn gestartet werden soll
...
Intent intent = new Intent(this, A.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
...
und Aktivität A, wenn Vorsatz empfängt, erzeugen Aktivität B unter Verwendung der gleichen Flagge.
Problem ist: Wenn ich derzeit nichts anzeigen (App ist geschlossen oder im Hintergrund), funktioniert es. Wenn ich auf Benachrichtigung klicken und Aktivität A wird aktuell angezeigt, funktioniert es auch, und ich habe diese Spur:
onActivityPaused(com.*****.A)
onActivityCreated(com..*****.A)
onActivityStarted(com..*****.A)
onActivityResumed(com..*****.A)
onActivityPaused(com..*****.A)
onActivityCreated(com..*****.B)
onActivityStarted(com..*****.B)
onActivityResumed(com..*****.B)
onActivityStopped(com..*****.A)
onActivityDestroyed(com..*****.A)
onActivityStopped(com..*****.A)
(Etwas ist seltsam, weil A gestoppt zweimal während meiner Flagge FLAG_ACTIVITY_CLEAR_TOP
sollte eine neue nicht neu erstellen ein?)
Aber wenn ich derzeit Aktivität B B, wird es gestartet dann gestoppt und zerstört ... Ich verstehe nicht, warum und ich brauche diese Aktivität zu (Neu-) starten. Hier die Spur:
onActivityPaused(com.*****.B) ? Why existing B is not destroyed ?
onActivityDestroyed(com.*****.A)
onActivityCreated(com.*****.A)
onActivityStarted(com.*****.A)
onActivityResumed(com.*****.A)
onActivityPaused(com.*****.A)
onActivityCreated(com.*****.B)
onActivityStarted(com.*****.B)
onActivityResumed(com.*****.B)
onActivityStopped(com.*****.B) ??
onActivityDestroyed(com.*****.B) ??
onActivityStopped(com.*****.A)
Was vergesse ich?
EDIT:
Mein Manifest ist:
<activity
android:name="com.*****.A"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.*****.B"
android:launchMode="singleTop" //Try just now with this line, should I keep it?
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Bitte senden Sie Ihre Manifest –