简体   繁体   中英

How to call another activity in android when notification received and app is in background

Tried all way but not getting output

 var intent = Intent(application, NavigationDrawerActivity::class.java)
 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
 startActivity(intent)

I solved this by sending (payload) data message instead of sending Notification.

 // Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
    Log.d(TAG, "Message data payload: " + remoteMessage.getData());

  sendNotification(remoteMessage.getData().get("message"));
 } 

Reference link - https://stackoverflow.com/a/37845174/11201011

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM