在按home键时 实现通知栏 上显示对应程序图标和文字,
然后点击该通知栏图标通过intent自动返回进入原来的activity
请问如果多个activity 怎么实现每一个activity对应的通知栏每个activity都添加一个通知Notification是可以实现,但是如果activity很多的话 有没有好一点的方法呢
然后点击该通知栏图标通过intent自动返回进入原来的activity
请问如果多个activity 怎么实现每一个activity对应的通知栏每个activity都添加一个通知Notification是可以实现,但是如果activity很多的话 有没有好一点的方法呢
解决方案 »
- android apn设置中关于不同运营商apn的问题
- 一个很原始的问题,C和Java是怎样连接起来的。
- 关于如何从服务器下载文件,并且显示出来的问题
- 如何取消AsyncTask正在执行的进程
- 如何把android里的几个img dump出来
- Sorry!the application activity(process com.activity)has stopped unexpectedly.ple
- NDK中对sdcard读写操作权限
- 使用一个开源的游戏引擎
- Android shell中有没有类似bashrc/profile这样的自动运行的脚本
- 求助,模拟器上可运行,但真机调试打开就闪退,跪求帮忙,在线等。
- 查找某个文件夹下以某关键字结束的文件名
- 强烈抗议网通/电信 屏蔽 http://developer.android.com/sdk/index.html
NotificationManager notificationManager = (NotificationManager)getSystemService(android.content.Context.NOTIFICATION_SERVICE);
// 定义Notification的各种属性
Notification notification = new Notification(R.drawable.taskbar_icon,
"AndroidUltrasound在后台运行……", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中
notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在点击了通知栏中的"清除通知"后,此通知不清除,经常与FLAG_ONGOING_EVENT一起使用
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults = Notification.DEFAULT_LIGHTS;
notification.ledARGB = Color.BLUE;
notification.ledOnMS = 5000;
// 设置通知的事件消息
CharSequence contentTitle = "AndroidUltrasound"; // 通知栏标题
CharSequence contentText = "超声程序正在运行"; // 通知栏内容
Context context = getApplicationContext();
System.out.println("Notification--->");
Intent notificationIntent = new Intent(context, AndroidUltrasound.class); // 点击该通知后要跳转的Activity
PendingIntent contentItent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentItent); // 把Notification传递给NotificationManager
notificationManager.notify(0, notification);
我想实现点击某条通知后在另外一个activity来显示具体的通知信息。
但是如何在activity中取到选择的具体某一条通知信息呢?
看下NotificationManagerService的源码,里面已经实现了,当点击click某个通知消息时,会响应启动相应的程序