简体   繁体   English

如何在收到通知且应用程序处于后台时调用 android 中的另一个活动

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

Tried all way but not getting output一路尝试但没有得到 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参考链接 - https://stackoverflow.com/a/37845174/11201011

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:当应用程序处于后台时。我想在通知点击时将 static 值 (1) 传递给 TotalRoomActivity 活动? - Android: When app is on background.I want to pass a static value (1) to TotalRoomActivity activity on notification click? 当我们在另一个应用程序中时,Android 10 来电通知就像 whats app - Android 10 Incoming call notification like whats app when we are in another app Firebase app在后台时如何处理通知 - How to handle notification when app in background in Firebase 应用程序被终止时,设备未收到推送通知 - push notification not received to devices when app is killed 如何在 Android Studio 中的后台应用程序时从 Android 通知中打开 URI - How to open URI from Android notification when the app on background in Android Studio 如何确保 firebase 已经收到应用服务器发送的推送通知,没有 android 应用程序 - How to ensure firebase has received push notification sent from app server, without android app 在 Firebase 上打开活动收到通知 - open activity on Firebase notification received 当应用程序在后台并单击通知时,Android react-native-push-notification onNotification 没有被调用? - Android react-native-push-notification onNotification not called when app is in the background and notification clicked? 当应用程序处于后台时发送鸟推送通知 - Sendbird push notification when app is in background Android 仅当应用程序处于前台时才播放推送通知声音,但当应用程序处于后台时不播放声音 - Android Push notification sound is played only when app is in foreground but not playing sound when app is in background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM