反应通知 [英] Reacting to notifications

查看:138
本文介绍了反应通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的应用程序时,有一个新电子邮件,短信或电话通知作出反应。

我可以使用NotificationManager创建通知,但不能从其他应用程序读取。

我已经看过AccessibilityManager,但我不能完全明白这一点无论是。

任何指针或例子?谢谢


解决方案

  1. 电子邮件。我不认为你可以使用非标准库做到这一点。也许它有意识寻找第三方API

  2. 短信。您shuold使用BroadcatReceiver行动=android.provider.Telephony.SMS_RECEIVED

  3. CALL。使用PhoneStateListener

TelephonyManager telephonyManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);

telephonyManager.listen(新PhoneStateListener(){

  @覆盖
   公共无效onCallStateChanged(INT状态,弦乐incomingNumber){
                 //做未便
   }
},PhoneStateListener.LISTEN_CALL_STATE);

I need my app to react when there is a notification about incoming email, sms or call.

I can use the NotificationManager to create notifications, but not read them from other apps.

I have looked at AccessibilityManager, but I can't quite figure that out either.

Any pointers or examples? Thanks

解决方案

  1. Email. I don't think you can do it using standart libraries. Probably it has sense to search third party API
  2. SMS. You shuold use BroadcatReceiver for ACTION ="android.provider.Telephony.SMS_RECEIVED"
  3. CALL. Use PhoneStateListener

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

telephonyManager.listen(new PhoneStateListener() {

   @Override 
   public void onCallStateChanged(int state,String incomingNumber) { 
                 //do smth
   } 
}, PhoneStateListener.LISTEN_CALL_STATE);

这篇关于反应通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆