Notification通知栏的基本使用
来源:互联网 发布:js表单数据的验证 编辑:程序博客网 时间:2024/06/01 07:55
public class MainActivity extends AppCompatActivity { Intent intent = new Intent(MainActivity.this,NotificationActivity.class); PendingIntent pi = PendingIntent.getActivity(MainActivity.this,0,intent,0);//这里的第一个是Contex,第二个是请求码,第三个是意图对象,第四个是标记,一般第二和第四我们是用不上的,所以一般都是传0 NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(MainActivity.this) .setContentTitle("This is content title")//设置标题 .setContentText("This is content text")//设置内容 .setWhen(System.currentTimeMillis())//设置时间 .setSmallIcon(R.mipmap.ic_launcher)//设置最小的图标 .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ma))//设置显示框的图标 .setContentIntent(pi)//设置点击的动作 .setSound(Uri.fromFile(new File("/system/media/audio/ringtones/Orion.ogg")))//设置通知的声音 .setVibrate(new long[]{0,1000,1000,1000})//设置消息的震动,第一个参数是消息来时静止时间,第二个是震动时间,第三个是静止时间,第四个是震动时间 .setLights(Color.GREEN,1000,1000)//设置消息通知灯的颜色,第一个是颜色,第二个是灯亮的时间,第三个是灯灭的时间 .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher)))//设置消息通知显示大图片// .setStyle(new NotificationCompat.BigTextStyle().bigText("Learn how to build notifications,send and sync data,and use voice actions. Get the official Android IDE and developer tools to build apps for Android."))//设置消息显示大文本 .setPriority(NotificationCompat.PRIORITY_MAX)//设置消息显示的优先级// .setAutoCancel(true)//设置消息点击之后被自动清除 .build(); manager.notify(1,notification);//设置消息,第一个是消息通知的ID,要保证其的唯一性,第二个是notification对象 }
阅读全文
0 0
- Notification通知栏的基本使用
- 通知栏(Notification)的基本使用
- 通知栏Notification基本使用
- 关于Notification通知的基本使用
- Android 通知栏 Notification 基本使用
- Notification通知栏的使用
- Notification通知栏的使用
- Notification 通知栏的使用
- Notification通知的使用
- Notification通知的基本用法
- Notification--------通知的基本用法
- 通知栏Notification使用
- android中通知栏notification的使用
- adnroid,notification通知栏的使用
- android通知栏(Notification)的使用
- android通知栏之Notification的使用
- Android--Notification通知栏的使用
- 通知栏notification的一些使用代码
- c# Json数据转换成DataSet
- elipse 里 File Seach 搜不出来任务结果,显示0 条 matched
- React 如何优雅地写单页面应用?
- Leetcode Insert Interval
- android播放有旋转角度的视频
- Notification通知栏的基本使用
- navicat for mysql 10.0.11简体中文破解版 绿色版
- JDK动态proxy原理解析
- mongodb3.4 Document Validation【文档验证】
- Linux下的守护进程
- C++:用CreateDirectory创建文件目录
- Android 手机休眠,进程仍存在
- LevelDB初探之简单使用 2014-07-28 17:16:18 分类: 大数据 一、简介 LevelDB是google开源的一个key-value存储引擎库,从版本1.2开始就
- nginx 配置后网站图片或js 加载出来一半或者不出来刷新才可以,chrome 浏览器访问项目时加载大文件失败 ERR_CONTENT_LENGTH_MISMATCH: