Android 从广播接收器启动活动
当我在广播接收器中接收到任何传输时,我正在尝试启动特定活动。在我的例子中,我收到一个推送通知,其中我定义我的PendingEvent应该是一个BroadCastReceiverAndroid 从广播接收器启动活动,android,push-notification,broadcastreceiver,Android,Push Notification,Broadcastreceiver,当我在广播接收器中接收到任何传输时,我正在尝试启动特定活动。在我的例子中,我收到一个推送通知,其中我定义我的PendingEvent应该是一个BroadCastReceiver val intentNotifications = Intent(applicationContext, MyBroadcastReceiver::class.java).apply { this.action = NOTIFICATION_ACTION this.setPacka
val intentNotifications =
Intent(applicationContext, MyBroadcastReceiver::class.java).apply {
this.action = NOTIFICATION_ACTION
this.setPackage(applicationContext.packageName)
putExtra(PUSH_ID, data.ID)
putExtra(DEEPLINK_ID_KEY, mbNotificationData.deepLink)
}
这就是我传递给NotificationManager创建推送通知的目的。在通知生成器中,我指定以下行:
intent?.let { setContentIntent(PendingIntent.getBroadcast(context, 0, it,
PendingIntent.FLAG_UPDATE_CURRENT)) }
在这一点上,似乎一切都是对的。我也在AndroidManifest中注册了我的接收者
<receiver android:name=".MyBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="action_notification"/>
</intent-filter>
</receiver>
但它似乎没有得到解决
我错过什么了吗
注意:我使用的是三星S10和安卓9