我想單擊通知在我的應用程序中啓動我的一項活動。 我設計了一個待定的意圖,如鏈接Notifications中所討論的。 但是,當我點擊通知時,會啓動一項活動,但這不是應該從我的應用程序啓動的活動。只有與我的活動具有相同類名的活動纔會啓動。我在我的活動中設置了一個斷點,並且斷點從未被擊中。 有什麼不對? NotificationListActivity是我喜歡發佈的一個。現在標題爲NotificationListActivity的活動啓動,但不是我的活動。單擊通知啓動應用程序的活動
Intent resultIntent = new Intent(thisclasscontext, NotificationListActivity.class);
resultIntent.putExtra("MOBILENUMBER", tel);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(thisclasscontext);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(NotificationListActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
參考?你的MainActiivty已經啓動,並說你有一個按鈕,當你點擊啓動出現,當你點擊通知你需要導航到NotificationListActivity?我很困惑 – Raghunandan
你可以發佈你的logcat嗎?你爲什麼會有兩個同名的活動? – Raghunandan
@Raghunandan當我從指定的號碼中獲得指定信息的短信時,我的應用程序發出通知。當用戶單擊我想要在我的應用程序 – Bryanyan