Ext淘宝公告栏怎么写通知栏

帮助开发者实现应用开发的资料库,提供丰富的安卓,ios开发文档和教程。
我们希望将问答区打造成 “有问必答,没有零回复”,能快速帮助大家解决燃眉之急。
全面关注移动互联网行业的发展趋势,分析移动互联网产业发展的特点和规律,提供各种app报告,汇聚移动产业观察者的独到观点。
移动电商就是利用手机、PDA及掌上电脑等无线终端进行的B2B、B2C或C2C等的电子商务,它是PC端电商的进化。移动电商分析尽在推优网。
专注APP推广营销,推优将努力尝试传播app营销的优秀理念,介绍国内外最新的app营销推广技术,总结实践经验分享。
全年不间断更新完善游戏攻略专区,人气爆棚。关注手机游戏领域!为您推荐各种好玩的手机游戏!
微信交友频道为开发者用户提供一个交友平台。海量开发者信息实时更新,轻松交友!推优微信导航网是目前国内最活跃的微信交友之一。
推优市场一直以开放的姿态面对广大开发者们,只要注册账号成功后登入,将应用提交上传并且通过审核,就能发布在推优市场内。
关于通知栏多按钮点击事件的问题,急!
本站会员发布于
15:38:18&&已经被浏览
1112 次&&&
我有一个service用来后台播放音频,现在我想在通知栏实现一个简易的控制器,就是可以控制播放暂停,点关闭可以清除通知,点通知栏可以跳到相应的activity,现在我是用remoteViews去实现的,但是点击事件会被覆盖,就是只能实现一个点击事件,能播放就不能暂停和清除,能清除就不能播放和暂停,相关代码如下,求大神解答!!!
& & public void show(Context context){
& && &&&if (Build.VERSION._INT &= 11){
& && && && &mRemoteView = new RemoteViews(context.getPackageName(), R.layout.radio_notification_layout);
& && && && &if(!TextUtils.isEmpty(mSharedPreferenceService.get(&play_program&, &&))){
& && && && && & mRemoteView.setTextViewText(R.id.title, mSharedPreferenceService.get(&play_program&, &&));
& && && && &}
& && && && &if(!TextUtils.isEmpty(mSharedPreferenceService.get(&play_name&, &&))){
& && && && && & mRemoteView.setTextViewText(R.id.desc, mSharedPreferenceService.get(&play_name&, &&));
& && && && &}
& && && && &Intent intent1 = new Intent(context, BroadcastService.class);
& && && && &intent1.putExtra(&play&, &play&);
& && && && &PendingIntent pendingIntent1 = PendingIntent.getService(context, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
& && && && &mRemoteView.setViewVisibility(R.id.play, View.GONE);
& && && && &mRemoteView.setViewVisibility(R.id.pause, View.VISIBLE);
& && && && &mRemoteView.setOnClickPendingIntent(R.id.play, pendingIntent1);
& && && && &Intent intent2 = new Intent(context, BroadcastService.class);
& && && && &intent2.putExtra(&play&, &pause&);
& && && && &PendingIntent pendingIntent2 = PendingIntent.getService(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
& && && && &mRemoteView.setViewVisibility(R.id.play, View.VISIBLE);
& && && && &mRemoteView.setViewVisibility(R.id.pause, View.GONE);
& && && && &mRemoteView.setOnClickPendingIntent(R.id.pause, pendingIntent2);
& && && && &Intent intent3 = new Intent(context, BroadcastService.class);
& && && && &intent3.putExtra(&play&, &stop&);
& && && && &PendingIntent pendingIntent3 = PendingIntent.getService(context, 0, intent3, PendingIntent.FLAG_UPDATE_CURRENT);
& && && && &mRemoteView.setOnClickPendingIntent(R.id.cancel, pendingIntent3);
& && && && &mNotification = new Notification();
& && && && &mNotification.icon = R.drawable.
& && && && &mNotification.flags = Notification.FLAG_ONGOING_EVENT|Notification.FLAG_NO_CLEAR;
& && && && &mNotification.number = 3;
& && && && &mNotification.contentView = mRemoteV
& && && && &PendingI
& && && && &if(!TextUtils.isEmpty(mSharedPreferenceService.get(&live_play_id&, &&)) && mSharedPreferenceService.get(&play_module&, &&).equals(&live&)){
& && && && && & Intent intent = new Intent(context, LiveBCDetail.class);
& && && && && & intent.putExtra(&id&, mSharedPreferenceService.get(&live_play_id&, &&));
& && && && && & p = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
& && && && &}else{
& && && && && & Intent intent = new Intent(context,VodBCDetailActivity.class);
& && && && && & intent.putExtra(&id&, mSharedPreferenceService.get(&vod_play_id&, &&));
& && && && && & p = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
& && && && &}
& && && && &mNotification.contentIntent =
& && && && &mNotificationManager.notify(NOTIFICATION_ID, mNotification);
文章分类:Android学习笔记10:状态通知栏 Notification - CSDN博客
1. &NotificationManager 和 Notification
& & & & & &在Android系统中,发一个状态栏通知还是很方便的。下面我们就来看一下,怎么发送状态栏通知,状态栏通知又有哪些参数可以设置?&
首先,发送一个状态栏通知必须用到两个类:NotificationManager、Notification。&
NotificationManager:是状态栏通知的管理类,负责发通知、清楚通知等。&
NotificationManager是一个系统Service,必须通过getSystemService()方法来获取。&
NotificationManagernm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);&
Notification:是具体的状态栏通知对象,可以设置icon、文字、提示声音、振动等等参数。
&2. 用法 :
& & & & &第一步 创建&NotificationManager & &&
& & &NotificationManagernm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);&
& & 第二步 设置Notification
//新建状态栏通知&
baseNF=newNotification();&
//设置通知在状态栏显示的图标&
baseNF.icon=R.drawable.&
//通知时在状态栏显示的内容&
baseNF.tickerText=&YouclickedBaseNF!&;&
//通知的默认参数DEFAULT_SOUND,DEFAULT_VIBRATE,DEFAULT_LIGHTS.&
//如果要全部采用默认值,用DEFAULT_ALL.&
//此处采用默认声音&
baseNF.defaults=Notification.DEFAULT_SOUND;&
//第二个参数:下拉状态栏时显示的消息标题expandedmessagetitle&
//第三个参数:下拉状态栏时显示的消息内容expandedmessagetext&
//第四个参数:点击该通知时执行页面跳转&
baseNF.setLatestEventInfo(Lesson_10.this,&Title01&,&Content01&,pd);&
其中 pd 是一个pendingIntent,它是怎么来的 :
& & & & & & & & //点击通知时转移内容
m_Intent = new Intent(Activity01.this, Activity02.class);
//主要是设置点击通知时显示内容的类
m_PendingIntent = PendingIntent.getActivity(Activity01.this, 0, m_Intent, 0);
第三步 &发出状态栏通知
nm.notify(Notification_ID_BASE,baseNF);
3. intnet 和 pendingIntent
& & & & & &&intent英文意思是意图,pending表示即将发生或来临的事情。&
PendingIntent这个类用于处理即将发生的事情。比如在通知Notification中用于跳转页面,但不是马上跳转。&
Intent 是及时启动,intent 随所在的activity 消失而消失。&
PendingIntent 可以看作是对intent的包装,通常通过getActivity,getBroadcast ,getService来得到pendingintent的实例,当前activity并不能马上启动它所包含的intent,而是在外部执行 pendingintent时,调用intent的。正由于pendingintent中
保存有当前App的Context,使它赋予外部App一种能力,使得外部App可以如同当前App一样的执行pendingintent里的 Intent, 就算在执行时当前App已经不存在了,也能通过存在pendingintent里的Context照样执行Intent。另外还可以处理intent执行后的操作。常和alermanger 和notificationmanager一起使用。&
Intent一般是用作Activity、Sercvice、BroadcastReceiver之间传递数据,而Pendingintent,一般用在 Notification上,可以理解为延迟执行的intent,PendingIntent是对Intent一个包装。[求助]ext2版本rom 想换白色通知栏_百度知道
[求助]ext2版本rom 想换白色通知栏
ext2版本rom 想换白色通知栏,就是和r12的rom一样的,不知谁能传个文件上来
提问者采纳
4# yangxinming@hko 过去57区看一下美化教程
查看原帖&&
其他类似问题
ext2的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁编写了一个Notification通知工具类,里面含有监听系统清除通知栏方法,焦点在加粗斜体部分:
public class Notifier { private static final String TAG = Notifier.class.getSimpleName(); private static N private Context mC
private static final int NOTIFICATION_ID_1 = 0; private static final int NOTIFICATION_ID_2 = 1; private static final int NOTIFICATION_ID_3 = 2; private static final int NOTIFICATION_ID_4 = 3; private static final int NOTIFICATION_ID_5 = 4; private static final int NOTIFICATION_ID_6 = 5; private static final int NOTIFICATION_ID_7 = 6; private static final int NOTIFICATION_ID_8 = 7;
public static Notifier getInstance(Context context) { if (instance == null) { instance = new Notifier(context); } }
public Notifier(Context context) { mContext = }
public NotificationManager getNotificationManager(Context context) { return (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); }
public void showNotify(Context context, int largeIcon, int smallIcon, CharSequence tickerText, CharSequence contentInfo, CharSequence contentTitle, CharSequence contentText) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), largeIcon); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder( context); // notifyBuilder.setLargeIcon(bitmap); notifyBuilder.setSmallIcon(smallIcon); notifyBuilder.setTicker(tickerText); notifyBuilder.setContentInfo(contentInfo); notifyBuilder.setContentTitle(contentTitle); notifyBuilder.setContentText(contentText); notifyBuilder.setAutoCancel(false); notifyBuilder.setWhen(System.currentTimeMillis()); notifyBuilder.setDefaults(Notification.DEFAULT_ALL); notifyBuilder.setContentIntent(contentIntent); Notification noti = notifyBuilder.build(); getNotificationManager(context).notify(NOTIFICATION_ID_1, noti); }
public void showCustomViewNotify(Context context, int smallIcon, CharSequence tickerText, int layoutId) { RemoteViews mRemoteViews = new RemoteViews(context.getPackageName(), layoutId); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder( context); notifyBuilder.setSmallIcon(smallIcon); notifyBuilder.setContent(mRemoteViews); notifyBuilder.setTicker(tickerText); notifyBuilder.setOngoing(true); notifyBuilder.setAutoCancel(true); notifyBuilder.setDefaults(Notification.DEFAULT_ALL); notifyBuilder.setContentIntent(contentIntent);
Notification noti = notifyBuilder.build(); Intent dismissedIntent = new Intent( &com.xxxx.android.notify.dismissed&); /** * The intent to execute when the notification is explicitly dismissed * by the user, either with the &Clear All& button or by swiping it away * individually. *& * This probably shouldn't be launching an activity since several of * those will be sent at the same time. */ noti.deleteIntent = PendingIntent.getBroadcast(context, 0, dismissedIntent, 0); getNotificationManager(context).notify(NOTIFICATION_ID_2, noti); }
public Notification getForegroundServiceNotify(Context context, int smallIcon, CharSequence tickerText, CharSequence contentInfo, CharSequence contentTitle, CharSequence contentText) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder( context); notifyBuilder.setSmallIcon(smallIcon); notifyBuilder.setTicker(tickerText); notifyBuilder.setContentInfo(contentInfo); notifyBuilder.setContentTitle(contentTitle); notifyBuilder.setContentText(contentText); notifyBuilder.setAutoCancel(false); notifyBuilder.setContentIntent(contentIntent); // notifyBuilder.setWhen(System.currentTimeMillis()); notifyBuilder.setDefaults(Notification.DEFAULT_ALL); return notifyBuilder.build(); } }如何拦截通知栏或监听消息_百度知道
如何拦截通知栏或监听消息
提问者采纳
&&&nbsp.notification_progress_green);&|=&Ongoing&=&Intent&&nbsp.PendingI&&&&title);&&&nbsp,&&&progressN&pIntent&nbsp,&&&&&&&&&&&nbsp,&&&&&&nbsp.NOTIFICATION_SERVICE);&nbsp,&&static&N&&nbsp,&&&&&&RemoteViews&&nbsp.cancel(notification_id);progressNotification&&Notification(&&&&&&&nbsp,&nbsp,&&&&&&&&&&nbsp.FLAG_AUTO_CANCEL;&&&icon).context&&&&&public&&&&&&&&&&nbsp.setImageViewResource(R;&nbsppublic&&&&&&&nbsp,&&&&//&&&&S0;|=&关闭对应的通知&&int&&&&PendingIntent&&&&&nbsp.&&int&&起一个线程用来更新progress&&&nbsp.notify(V&icon.contentView&&&将此通知放到通知栏的&&&closeNotification(Context&&&&&&nm&清除通知&&&表明在点击了通知栏中的&&&&nbsp,&&&&nbsp.currentTimeMillis());&&&&&&&&&&&Notification&&&&&&&&&&&&&&&&&&&&&&&RemoteViews(&&&&&(NotificationManager)&&&&&&nbsp.&&nbsp,&&&&&nbsp.getSystemService(C&&&&(NotificationManager)&&&&&&&&&&&&&//&&&&&&&&&&&&&&nbsp.flags&R;intent&&&&&nbsp.getSystemService(C通知的图标必须设置(其他属性为可选设置);&&&&//&&&nbsp.NOTIFICATION_SERVICE);&nbsp.getPackageName();&&&&&&&&&NotificationManager&&&&&&&&=&nbsp,&&nbsp,&&&&&&&&&&&&&&&&&&&&=&&&&context,否则通知无法显示&String&&notification_id)&new&nbsp.FLAG_UPDATE_CURRENT);&&&&&&=&&&&&&&&&&&&&&&&&&&&&&nbsp.setClass(&&=&&&&&static&&&nbsp.contentIntent&&&&&&//&&&&&&&&&&&&&&&&&&nbsp.&&PendingIntent.DOWNLOAD_NEWS_NF_ID;&&void&&&=&&&false);&组中&view&nbsp,&&//&&.class);&showDownloadNotification(Context&nbsp.FLAG_ONGOING_EVENT;&&&&&&&&&progressN&&progress)&new&&&&progressNotification);&&&&nbsp,此通知不清除;Intent();&&&&new&&&&//&&&&&&&&pI&&&&&&&pIntent&&&&&&&nbsp.setTextViewText(R;&nbsp,&&&&&&&&int&&&&=&&nbsp.setProgressBar(R;NotificationManager&&&&&&&&&&&&&&&&&&&&&&void&{&&&nm&&&intent,&根据notification_id&&&&&&&&&&&&nbsp.&&&int&&后;&&&nbsp,&progressN&&nbsp,&nbsp,&&&&&context&&&&&&&&即&&&&&&&&&&&&&正在运行&&&&&nbsp.}&view&&&&&&&;&&&&&&&&&&&&&&&&&nbsp.flags&&nbsp.getActivity(&N&&&&=&&&更新显示&&&&&&&&&&&&&&&&&&=&&&&&&&DownlodeA&&progressN&=&&&&&&&&&&&nbsp,&&&&&&&&{&&&&&&context
其他类似问题
监听的相关知识
按默认排序
其他1条回答
你用的啥子版本的手机
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 通知怎么写 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信