android通知栏内添加快捷键_Android 添加 通知栏控制组件

public voidupdateNotification() {boolean isShow=false;if (SettingInfo.shareInstance().isNotifyPlugin()||MyTrackInfo.getInstance().isStart()){

isShow=true;

}if (!isShow){

((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(notify_info);

((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(notify_control);return;

}if (mNotificationControl == null) {

mNotificationControl= new Notification(R.drawable.ic_launcher, "NotificationName", System.currentTimeMillis());

mNotificationControl.flags= Notification.FLAG_ONGOING_EVENT |Notification.FLAG_NO_CLEAR;

RemoteViews contentView= newRemoteViews(mContext.getPackageName(), R.layout.layout_notify_control);

mNotificationControl.contentView=contentView;

PendingIntent pendingIntent1= PendingIntent.getBroadcast(mContext, 0, new Intent(NotificationBroadcastReceiver.CLICK_ACTION_BUTTON_1), 0);

contentView.setOnClickPendingIntent(R.id.button1, pendingIntent1);

PendingIntent pendingIntent2= PendingIntent.getBroadcast(mContext, 0, new Intent(NotificationBroadcastReceiver.CLICK_ACTION_BUTTON_2), 0);

contentView.setOnClickPendingIntent(R.id.button2, pendingIntent2);

}if (MyTrackInfo.getInstance().getStatus() ==MyTrackInfo.status_create) {

mNotificationControl.contentView.setTextViewText(R.id.button1,"开始室内");

mNotificationControl.contentView.setTextViewText(R.id.button2,"开启户外");

}else if (MyTrackInfo.getInstance().getStatus() ==MyTrackInfo.status_resume) {

mNotificationControl.contentView.setTextViewText(R.id.button1,"暂停");

mNotificationControl.contentView.setTextViewText(R.id.button2,"结束");

}else if (MyTrackInfo.getInstance().getStatus() ==MyTrackInfo.status_pause) {

mNotificationControl.contentView.setTextViewText(R.id.button1,"继续");

mNotificationControl.contentView.setTextViewText(R.id.button2,"结束");

}if (mNotificationInfo == null) {

mNotificationInfo= new Notification(R.drawable.ic_launcher, "notificationName", System.currentTimeMillis());

mNotificationInfo.flags= Notification.FLAG_ONGOING_EVENT |Notification.FLAG_NO_CLEAR;

RemoteViews contentView= newRemoteViews(mContext.getPackageName(), R.layout.layout_notify_info);

PendingIntent contentIntent= PendingIntent.getBroadcast(mContext, 0, new Intent(NotificationBroadcastReceiver.CLICK_ACTION_BUTTON_OPEN), 0);

mNotificationInfo.contentIntent=contentIntent;

mNotificationInfo.contentView=contentView;

}mNotificationInfo.contentView.setTextViewText(R.id.textView1, TimeUtils.second2Time(13:12:31 00:00:00));mNotificationInfo.contentView.setTextViewText(R.id.textView2, RunningUtils.getMeterStr(31));mNotificationInfo.contentView.setTextViewText(R.id.textView3, TimeUtils.second2Pace(3));if (mNotificationManager == null) {

mNotificationManager=(NotificationManager) mContext.getSystemService(mContext.NOTIFICATION_SERVICE);

}

mNotificationManager.notify(notify_info, mNotificationInfo);

mNotificationManager.notify(notify_control, mNotificationControl);//if (totalSec%5==0) {

mContext.sendBroadcast(newIntent(ControlAllWidgetProvider.ACTION_CONTROL_UPDATE));//}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值