[英]How to choice activity to open when notification clicked
有沒有選擇活動的方法,該活動僅在單擊通知時立即開始? 構建通知時可以使用setContentIntent
。 但是一旦顯示出來,似乎無法在點擊時設置或更改內容意圖...
我建議的解決方法是將setContentIntent定向到一個簡單的活動,該活動根據您選擇的意圖在onCreate()中處理特定情況。
嘗試這個
Intent intent = new Intent(this, YOURACTIVITY.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentIntent(pendingIntent);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.