Notification在Android中的应用
16lz
2021-01-23
// A、首先需要获取系统Notification服务 NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // B、创建Notification,参数为别为图标、提示标题、提示时间 Notification notification = new Notification(R.drawable.icon,"即兴提示aa!",System.currentTimeMillis()); //System.currentTimeMillis() // C、创建意图Intent并转化为非即时意图,这样就可以在任何不确定时间被执行 Intent intents = new Intent(FirstActivity.this,TestActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(FirstActivity.this,0,intents,0); // D、设置Notification标题、内容和触发事件 notification.setLatestEventInfo(FirstActivity.this, "ATAAW.COM", "即兴时代!", contentIntent);
notification.flags|=Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_SOUND; // E、开启提示 notificationManager.notify(1,notification);// // F、取消提示// notificationManager.cancel(1);
更多相关文章
- Android实现自动文本框提示功能
- android设置eclipse中的自动提示功能
- Android获取状态栏、标题栏、ActionBar以及屏幕的高度
- Android——系统提示对话框(AlertDialog)
- Android 状态栏和应用标题栏颜色保持一致
- Android标题头滑动渐变,Titlebar滑动渐变,仿美团饿了么标题头渐变;
- Android Activity去除标题栏和状态栏(z)
- 拷贝的Android源码不能单独编译mmm命令提示找不到
- 自定义Activity标题栏(Title bar)和窗体显示状态操作(requestWind