单击通知时将数据发送到活动?

瑞沙·阿加瓦尔

单击通知时,我正在打开一个活动。通知是从服务类激活的。我想将数据发送到从通知中打开的新活动我正在使用 intent1.putExtra("lable",lable); 但在新活动中,它给了我空指针豁免。

 intent1 = new Intent(this.getApplicationContext(), simplestop.class);
            intent1.putExtra("lable",lable);

PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent1, 0); 
Notification mNotify  = new Notification.Builder(this)
            .setContentTitle("title" + "!")
            .setContentText("Click me!")
            .setSmallIcon(R.drawable.ic_launcher_background)
                            .setContentIntent(pIntent)
            .setAutoCancel(true)
            .build();
朴雅卡

我使用此代码将数据发送到activity.

Intent intent = new Intent(this, MainActivity.class)
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.putExtra("from", "notification");
                    pIntent = PendingIntent.getActivity(this, 3, intent,
                            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);

可能是您在设置flag=0或尝试将请求更改code=0为任何其他整数时遇到问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Android中单击Firebase通知时将数据发送到活动

将数据发送到父活动

将数据从服务发送到活动

将数据从活动发送到WearableListenerService

当用户单击Android中的“后退”按钮时,如何将数据从活动发送到片段?

如何将参数从通知单击发送到活动?

在使用jQuery将数据发送到数据库时,如何使按钮处于活动状态?

ViewPager-将数据从片段发送到活动时,Android错误setCurrentItem(int,boolean)

jQuery ajax调用,以在单击a href时将数据发送到该方法

单击按钮以使用 jQuery 将数据发送到服务器时网页消失

将数据从活动发送到已创建的片段

将数据发送到活动中的片段

使用EventBus将数据发送到活动中的片段

将活动中的数据发送到Android中的片段

将数据从活动发送到服务UPDATED

将数据(ArrayList)从活动发送到片段

将数据从Android活动发送到React Native

如何将数据从活动发送到Java类

将数据从片段发送到活动 android C#

将数据从视图分页器发送到活动

将数据从“活动”发送到“类范围”片段

使用意图将数据从clicklistener发送到活动

将数据从Android库发送到主项目活动

如何将数据从片段发送到活动?

reactjs - 单击时将参数发送到函数

在服务器中的数据更新后将推送通知发送到Android应用,并打开自定义活动

当单击网格视图时,如何将arralist(position)发送到另一个活动

我无法通过单击一个按钮将多个数据发送到新活动

在将数据发送到后端时显示数据