博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android 通知消息一
阅读量:4694 次
发布时间:2019-06-09

本文共 892 字,大约阅读时间需要 2 分钟。

记录android 通知消息

NotificationManager 通知消息管理(发送,取消)

 

notifcation 消息肉容的设置,提醒音乐;

 

activity1中的onCreate

 

        String title ="测试消息";

                
                String content ="通知工作日期到期";
            
                PendingIntent intent = PendingIntent.getActivity(MainActivity.this, 0, new Intent(MainActivity.this, SecActivity.class), 0);
                
                //title标题栏显示的文字
                Notification notifcation = new Notification(R.drawable.ic_launcher, title, System.currentTimeMillis());
                
                //设置具体内容和标题
                notifcation.setLatestEventInfo(MainActivity.this, title, content, intent);
            
                //设置默认声音
                notifcation.defaults = Notification.DEFAULT_SOUND;
                
                //通知管理
                NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
            
                //发送通知
                notificationManager.notify(2, notifcation);

 

 

SecActivity中的onCreate

        NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

        
        //取消通知
        nm.cancel(1);

转载于:https://www.cnblogs.com/xhfjiao/archive/2012/10/16/2725866.html

你可能感兴趣的文章
git常用操作
查看>>
京东SSO单点登陆实现分析
查看>>
u-boot启动第一阶段
查看>>
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>
C#中StreamReader读取中文出现乱码
查看>>
使用BufferedReader的时候出现的问题
查看>>
批处理文件中的路径问题
查看>>
hibernate出现No row with the given identifier exists问题
查看>>
为什么wait()和notify()属于Object类
查看>>
配置NRPE的通讯
查看>>
shp系列(一)——利用C++进行shp文件的读(打开)与写(创建)开言
查看>>
匹配两个空格之间的字符。。。
查看>>
CSS 文字溢出 变成省略号 ...
查看>>
Spring事务
查看>>
java编程基础(三)流程控制语句
查看>>
让数据库跑的更快的7个MySQL优化建议
查看>>
jquery 取id模糊查询
查看>>
解决在vue中,自用mask模态框出来后,下层的元素依旧可以滑动的问题
查看>>