简单的Android通知
来源:互联网 发布:84aaa最新域名升级 编辑:程序博客网 时间:2024/05/01 03:39
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn=findViewById(R.id.mi); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Notification .Builder no=new Notification.Builder(v.getContext()); no.setSmallIcon(R.drawable.icon); no.setTicker("您有一条消息!"); no.setContentTitle("小米发来一条消息:"); no.setContentText("媳妇,早上吃了没?我现在在上班,嘻嘻��"); no.setDefaults(Notification.DEFAULT_ALL); Intent intent=new Intent(Main.this,OneActivity.class); PendingIntent pi=PendingIntent.getActivity(Main.this,1,intent,PendingIntent.FLAG_CANCEL_CURRENT); no.setContentIntent(pi); Notification n=no.build(); n.flags=Notification.FLAG_NO_CLEAR; NotificationManager m=(NotificationManager)getSystemService(NOTIFICATION_SERVICE); m.notify((int) (Math.random() * 1000), n); } }); }
自己研究咯
阅读全文
0 0
- 简单的Android通知
- Android中简单的通知
- Android中通知的简单使用和自定义通知样式
- Android的Notification通知的简单实用
- Android API- Notification(通知)的简单使用
- android -- 通知栏的简单应用
- Android简单的消息通知栏
- 通知的简单使用
- 简单的通知
- 通知的简单运用
- 通知的简单实现
- Android 简单创建一条通知
- 简单创建Android状态栏通知
- Android Notification 通知 简单使用
- Android 简单 通知栏 Notification
- 【转】Android通知的使用及简单二次封装
- Android开发学习之Notification通知的简单实现
- Android中通知(Notification)的简单使用
- JavaScript:prototype属性使用方法
- weblogic10.3 启动报错 Unrecognized option: -jrockit Error: Could not create the Java Virtual Machine
- Ethernet/IP 学习笔记五
- C#与excel互操作 C#与excel互操作的错误无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 对象强制 如果您使用的电脑
- 用npm安装vue和vue-cli,并使用webpack创建项目
- 简单的Android通知
- SpringBoot探索_1
- Android 之 Activity活动(一、新建activity)
- 免费谷歌卫星地图下载器
- linux下scp远程拷贝文件无需输入密码工具之expect
- 浅析protobuf(未完待续)
- 跨境茶话会8月期丨性能优化的艺术
- JavaScript动画之完美运动框架
- 误删数据恢复