BroadcastReceiver的+ SMS_RECEIVED [英] BroadcastReceiver + SMS_RECEIVED

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

问题描述

我想我的应用程序,以赶上收到的短信。有此周围的几个例子。看起来我们只需要做到这一点:

I'd like my app to catch incoming SMS messages. There are a few examples of this around. Looks like we just need to do this:

// AndroidManifest.xml
<receiver android:name=".SMSReceiver"> 
  <intent-filter> 
    <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
  </intent-filter> 
</receiver>        

// SMSReceiver.java
public class SMSReceiver extends BroadcastReceiver 
{ 
    @Override 
    public void onReceive(Context context, Intent intent) { 
        Log.i(TAG, "SMS received.");
        ....
    }
}

这是正确的?我送我的手机有些短信,但日志语句永远不会被打印出来。我有在手机上安装一些其他的短信应用,这显示在接收到的短信弹出? - 是他们以某种方式阻止来自越来越向下传递给我的应用程序的意图,他们只是完全消耗它

is this correct? I'm sending my phone some sms messages, but the log statement never gets printed. I do have some other SMS applications installed on the phone, which display a popup when the sms is received - are they somehow blocking the intent from getting passed down to my app, they are just consuming it completely?

感谢

推荐答案

您还需要在你的manifest文件指定用途,权限:

You would also need to specify a uses-permission in your manifest file:

<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> 

下面的教程应该帮助:

The following tutorials should help:

阵营在接收到的SMS
短信Android中

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

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