我有一個'列表'活動,點擊時開始'文章'活動。 我也有推送通知,直接打開'文章'活動。如何正確定義活動和意圖以按照需要行事?
我改變了後退按鈕行爲在「文章」活動啓動「清單」的活動,從通知到來時,這樣用戶將返回到文章列表。
問題是,當應用程序在後臺已經打開,我打開的通知 - 它只是把它帶回前面。 我想要實現的是打開正確的文章,當點擊通知並返回到「列表」活動時,沒有可能列表活動將打開兩次。
我試圖分開的「文章」的任務,並創建通知意向新的任務,但隨後打開多個通知,並單擊後退時,它會打開單獨的「清單」的活動。
什麼是確定活動的任務和意圖的標誌,以實現我的目標的正確方法是什麼?
編輯: 清單部分:
<activity android:name="ListFeed" android:configChanges="orientation|screenLayout" android:launchMode="singleInstance" android:screenOrientation="unspecified"
android:taskAffinity="com.app.MyTask"></activity>
<activity android:name="Article" android:launchMode="standard" android:configChanges="orientation|screenLayout" android:screenOrientation="unspecified"
android:taskAffinity="com.app.MyTask"></activity>
通知意向:
Intent notificationIntent = new Intent(context, Article.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, notificationID, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
謝謝!
發佈您的清單,並顯示您用於爲通知創建PendingIntent的代碼。 – 2012-07-08 19:31:45
發佈爲編輯問題 – 2012-07-08 20:20:41