读取通知栏消息
来源:互联网 发布:淘宝网折800唯影女装 编辑:程序博客网 时间:2024/05/22 00:46
android4.4以后的版本出现了一个NotificationListenerService(通知监听服务类),因此,我们只需要继承这个服务,然后在
Manifest.xml中注册即可。
package com.example.demo;import android.app.Notification;import android.app.Notification.Action;import android.app.PendingIntent;import android.content.Intent;import android.os.Bundle;import android.service.notification.NotificationListenerService;import android.service.notification.StatusBarNotification;import android.util.Log;import android.widget.Toast;public class NotificationService extends NotificationListenerService {@Overridepublic void onNotificationPosted(StatusBarNotification sbn) {Notification mNotification = sbn.getNotification();if (mNotification != null) {String packageName=sbn.getPackageName();//发送通知的包名String text=mNotification.tickerText.toString());//通知内容}}@Overridepublic void onNotificationRemoved(StatusBarNotification sbn) {// TODO 自动生成的方法存根}}
<service android:name="com.example.demo.NotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > <intent-filter> <action android:name="android.service.notification.NotificationListenerService" > </action> </intent-filter> </service>
并且需要调用这个让用户在系统设置中授权应用能够读取通知。
Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");startActivity(intent);所以由此可见,经过授权的应用是可以读取通知栏消息的,假如用户随便授权应用,就可能让不良应用读取你手机中的隐私
信息,例如各类验证码,聊天工具消息。
0 0
- 读取通知栏消息
- Android读取通知栏消息数、处理消息
- Android 通知栏消息
- Android 通知栏消息
- 定义通知栏消息
- android 通知栏消息
- android通知栏区分多通知消息
- Notification消息通知 通知栏的实现
- 通知栏消息通知详解(Notification)
- android通知栏的消息通知(Notification)
- 消息栏通知(Notification)介绍
- Android消息通知栏应用
- 消息栏通知(Notification)介绍
- android的消息通知栏
- Android消息通知栏开发
- 消息栏通知(Notification)介绍
- 监听通知栏中的消息
- 安卓消息通知栏
- 关于模式识别、机器学习、推荐系统、图像特征、数值计算、目标跟踪知识专家博客
- 实战录 | Wuli测试媛推荐的构造大数据量的方法
- 链表数据结构
- Ubuntu安装deb及依赖
- 修改android签名证书keystore
- 读取通知栏消息
- OC里面UIWebView中js交互
- leetcode 225. Implement Stack using Queues
- UML基本表示法
- Eclipse中自动添加注释(作者,时间)
- 51nod 1087 1 10 100 1000
- 深度学习FPGA实现基础知识3(Altera与百度展开合作在云数据中心使用FPGA加速)
- Asp.net教师管理系统源码
- "EIPAbstractError" exception with "No peer with the interface with guid [...] has been registered".