Intent 通知的Flag定义
来源:互联网 发布:linux下怎么退出vi 编辑:程序博客网 时间:2024/04/29 10:23
// 第一种情况,点击通知栏,不会出现两个相同Activity出现
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,
"来了一个通知", System.currentTimeMillis());
notification.defaults = Notification.DEFAULT_ALL;
notification.flags = Notification.FLAG_ONGOING_EVENT;
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
// 预备式的Intent
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this, "消息的内容标题", "通知的内容.....",
contentIntent);
manager.notify(1, notification);
// 第二种情况,通知栏点击打开应用当前界面,不指定某个Activity
// 当点击通知的时候,当前应用当前界面。
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(getPackageName(),
"com.dashuai.music.qd.SplashActivity(第一个Activity,需要自信修改)"));
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
0 0
- Intent 通知的Flag定义
- Intent的Flag
- Intent的Flag
- Intent的Flag属性
- Android的Intent Flag
- intent的flag标志
- Intent的Flag总结
- Intent对象内置的Flag
- Android Intent Flag的介绍
- 常用的Intent Flag 说明
- Intent 传递的flag基本常识
- Android Intent Flag的介绍
- Android Intent Flag的介绍
- Intent对象内置的Flag
- Android Intent Flag的介绍
- Android Intent Flag的介绍
- Android Intent Flag的介绍
- Intent的常用Flag参数:
- leetcode刷题日记——Ugly Number
- 给Jquery动态添加的元素绑定事件
- VC驿站精彩
- 让IIS8支持WCF的最简单方法
- I wanna communicate!
- Intent 通知的Flag定义
- 安卓开发笔记(一)------------自定义按钮
- 数据泵导出/导入Expdp/impdp
- XHR是什么?
- [TYVJ] P1017 冗余关系(经典并查集)
- 操作系统探索之计算机的启动(一)
- 【编译原理】:如何通过正规式写DFA
- 利用@media screen实现网页布局的自适应
- 控制双端通用链表