我收到了一些關於通知意圖的問題。我有2項活動(A & B)。活動A是我的應用程序的主要活動。用戶將經歷的第一個活動。至於活動B是當用戶通過點擊活動A上的按鈕進入時。通知意圖活動
事情是當我點擊我的通知時,它會引導我進入活動B.然後指引我回到活動A onBackPressed。但是,當我關閉應用程序並通過多任務選項將其打開時,它會在Activity B恢復我的應用程序。我希望應用程序在關閉它之後開始回到Activity A。
順序應是
活性A - >活動B.
通知的onClick - >活動B(onBackPressed) - >活動A - >關閉。
重新打開應用/多任務功能開 - >活動A
請不要讓我知道是否有任何其他信息,我可以給我的問題提供了一個正確的認識。
GCM_Intent.class
Notification note = new Notification(icon, msgTopic ,System.currentTimeMillis());
Intent i=new Intent(this, Activity_B.class);
i.putExtra("topicId", topicId);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi=PendingIntent.getActivity(this, CommunitiesappConstant.NOTIFICATION_ID, i, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
note.setLatestEventInfo(this, topicName ,msgInfo+message, pi);
note.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
note.ledARGB |= 0xff0000ff;
note.ledOffMS |= 1000;
note.ledOnMS |= 300;
mgr.notify(CommunitiesappConstant.NOTIFICATION_ID, note);
活動B.class
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_b);
Bundle bundle = getIntent().getExtras();
topicId = bundle.getString("topicId");
}
@Override
public void onBackPressed() {
super.onBackPressed();
Log.e(TAG, "onBackPressed");
Intent i = new Intent(Activity_B.this, Activity_A.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
finish();
}
凡正是我需要將這個代碼? 我想在我的網站上發佈任何新帖子時向用戶顯示通知..我使用WebView創建了一個Android應用程序 – Neo