为什么我这么写Android的通知点击按钮的时候通知发不出来?附代码
NotificationManagernm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);Not...
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification nf = new NotificationCompat.Builder(getApplicationContext())
.setContentTitle("通知")
.setContentText("通知的内容")
.setWhen(System.currentTimeMillis())
.build();
nm.notify(1,nf); 展开
Notification nf = new NotificationCompat.Builder(getApplicationContext())
.setContentTitle("通知")
.setContentText("通知的内容")
.setWhen(System.currentTimeMillis())
.build();
nm.notify(1,nf); 展开
2017-08-11
展开全部
//注册按钮广播privatevoidsetButtonBroadCast(){finalStringSTATUS_BAR_COVER_CLICK_ACTION="download";getDownNotification().contentView.setViewVisibility(R.id.downloadCancle,View.VISIBLE);BroadcastReceiveronClickReceiver=newBroadcastReceiver(){privatebooleanflag=false;@OverridepublicvoidonReceive(Contextcontext,Intentintent){if(intent.getAction().equals(STATUS_BAR_COVER_CLICK_ACTION)){//在这里处理点击事件interceptFlag=true;//取消通知栏}}};IntentFilterfilter=newIntentFilter();filter.addAction(STATUS_BAR_COVER_CLICK_ACTION);mContext.registerReceiver(onClickReceiver,filter);IntentbuttonIntent=newIntent(STATUS_BAR_COVER_CLICK_ACTION);PendingIntentpendButtonIntent=PendingIntent.getBroadcast(mContext,0,buttonIntent,0);getDownNotification().contentView.setOnClickPendingIntent(R.id.downloadCancle,pendButtonIntent);//R.id.trackname为你要监听按钮的id//mRemoteViews.setOnClickPendingIntent(R.id.trackname,pendButtonIntent);});
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-08-11
展开全部
利用AndroidStudio编制一个小程序,应该很容易做到
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询