前几天发的帖子可能是我描述的不清,所以尽管很多人回复也让大家失望了,这次在标题中仔细说明一下要求就是
其实我就是想在状态栏添加一个像qq的小图标,点击后还能回到那个窗口...........
有人推荐使用的方式如下,但是实际无法上图标在能在状态栏显示,但是无法回到原来的Activity只是有个提示罢了。
// 设置通知的事件消息 CharSequence contentTitle = "天籁之音正在播放……";
// 通知栏标题 CharSequence contentText = "ameyume";
// 通知栏内容 Intent notificationIntent = new Intent(context, MusicDemo.class);
// 点击该通知后要跳转的Activity PendingIntent contentItent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentItent);
http://www.blogjava.net/anymobile/articles/340720.html说是和QQ一样的机制,但是没发现管用。
向高手求助了!!
原来帖子的网页为http://topic.csdn.net/u/20110106/14/faa4340b-f5e1-46dc-9895-81d585c41ec7.html
其实我就是想在状态栏添加一个像qq的小图标,点击后还能回到那个窗口...........
有人推荐使用的方式如下,但是实际无法上图标在能在状态栏显示,但是无法回到原来的Activity只是有个提示罢了。
// 设置通知的事件消息 CharSequence contentTitle = "天籁之音正在播放……";
// 通知栏标题 CharSequence contentText = "ameyume";
// 通知栏内容 Intent notificationIntent = new Intent(context, MusicDemo.class);
// 点击该通知后要跳转的Activity PendingIntent contentItent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentItent);
http://www.blogjava.net/anymobile/articles/340720.html说是和QQ一样的机制,但是没发现管用。
向高手求助了!!
原来帖子的网页为http://topic.csdn.net/u/20110106/14/faa4340b-f5e1-46dc-9895-81d585c41ec7.html
解决方案 »
- 小菜求助 关于listview的问题
- android 怎么改变imagebutton焦点
- GestureDetector构造器弃用
- Android 语言开发一个手机游戏
- 新手求教intent问题
- 用opengl做了一个动画效果,想知道怎么让它进行快一点
- listview点击出现删除按钮(带动效),如何使其每次点击都能有动效
- android的/mnt/sdcard/通用路径
- android 华为手机广播注册过多!
- 安装android studio 出现could not find main class com/litellij/idea/Main
- [求助]Android系统中AIDL机制和Message机制各有何优缺点?
- Android开发者应该保持以下特质(转自 安卓巴士)
1.manifest.xml中,activity设置了singleTask属性,receiver 中增加了NOTIFICATION的intent-filter <activity android:name=".MusicDemo"
android:label="@string/app_name" android:launchMode="singleTask"> <receiver android:name=".MusicReceiver">
<intent-filter>
<action android:name="com.min.musicdemo.action.NOTIFICATION"/>
</intent-filter>
2.在MusicReceiver中
// Start activity
if (intent.getAction().equals(Common.NOTIFICATION_RECEIVER)) {
showNotification();
}
} private void showNotification() {
// 创建一个NotificationManager的引用
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
// 定义Notification的各种属性
Notification notification = new Notification(R.drawable.icon,
"天籁之音播放器", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中
notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在点击了通知栏中的"清除通知"后,此通知不清除,经常与FLAG_ONGOING_EVENT一起使用
...
// 设置通知的事件消息
CharSequence contentTitle = "天籁之音正在播放……"; // 通知栏标题
CharSequence contentText = "ameyume"; // 通知栏内容
Intent notificationIntent = new Intent(context, MusicDemo.class); // 点击该通知后要跳转的Activity
PendingIntent contentItent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentItent); // 把Notification传递给NotificationManager
notificationManager.notify(0, notification);
}