Android,从通知点击重用同一活动
创始人
2024-10-13 08:00:29
0

在通知点击时启动同一活动,并设置标志来检测是否需要创建新的实例。代码示例:

// on create boolean isFromNotification = false; Bundle extras = getIntent().getExtras(); if (extras != null) { isFromNotification = extras.getBoolean("FROM_NOTIFICATION", false); }

if (isFromNotification) { // do something when starting from notification } else { // do something else when starting normally }

// on notification click Intent intent = new Intent(this, MyActivity.class); intent.putExtra("FROM_NOTIFICATION", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Notification Title") .setContentText("Notification Text") .setContentIntent(pendingIntent);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, builder.build());

相关内容

热门资讯

每日必看教程!智星菠萝辅助,h... 每日必看教程!智星菠萝辅助,hhpoker透视脚本下载,必赢教程(有挂技巧);科技安装教程;1367...
推荐十款!pokemmo手机辅... 推荐十款!pokemmo手机辅助软件,hhpoker有没有外挂,大神讲解(有挂攻略)是一款可以让一直...
终于懂了!红龙poker辅助平... 终于懂了!红龙poker辅助平台,pokemmo脚本,详细教程(有挂技巧);致您一封信;亲爱红龙po...
让我来分享经验!wepoker... 1、让我来分享经验!wepoker私人局辅助,wepoker怎么设置透视,新2025版(有挂技巧)。...
每日必看推荐!wepoker有... 每日必看推荐!wepoker有没有辅助,cloudpoker怎么开挂,新版2025教程(有挂方法)关...
分享实测!wepoker提高好... 分享实测!wepoker提高好牌率,wepoker有没有辅助,必备教程(有挂攻略);实战中需综合运用...
避坑细节!hhpoker破解工... 自定义wepoker插件功能辅助器系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用...
今日头条!德州透视是真的吗,w... 今日头条!德州透视是真的吗,wejoker辅助机器人,科技教程(有挂透明)是一款可以让一直输的玩家,...
免费测试版!wepoker私人... 免费测试版!wepoker私人局怎么玩,we poker辅助器,专业教程(有挂攻略);支持多人共享记...
我来分享!aa poker辅助... 我来分享!aa poker辅助包,wepoker作弊方法,揭秘攻略(有挂软件);1分钟了解详细教程(...