2012-04-11 83 views
0

我的bradcastreceiver中的onreceived函数没有被触发。Android SMS_RECEIVED broadcastreceiver没有被调用

我通过发送来自不同手机的短信消息来测试此功能,但日志似乎没有显示任何活动。

这里是接收机类

package nz.co.smstopc; 

import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.util.Log; 

public class SmsListener extends BroadcastReceiver{ 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     //---get the SMS message passed in--- 
     Log.d("SmsListener", "new sms!!"); 
    } 
} 

这里是minifest.xml

<receiver android:name=".smstopc.SmsListener"> 
     <intent-filter>           
      <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
     </intent-filter> 
    </receiver> 

这是我用过的权限。

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

我已经试过一切来解决这个问题。 我错过了什么可以添加在最小的?

+1

可能存在任何其他正在接收短信并阻止其进一步发送的应用程序。 – Relsell 2012-04-11 07:34:27

+0

即时通讯使用短信应用程序,可以阻止它? – 2012-04-11 07:36:46

+1

也许它可以..我不知道它是如何编码..但它可以.. – Relsell 2012-04-11 07:39:21

回答

1

我也用同样的方式,但我的清单,文件看起来只是有点不同:

<receiver android:name=".receiver.SmsBroadcastReceiver" > 
    <intent-filter android:priority="99999999" > 
      <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
    </intent-filter> 
</receiver> 
0

在接收器可在清单标签封装属性冲突的包名 试试这个

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="your package name" 
... 
... 
... 
<receiver android:name="nz.co.smstopc.SmsListener"> 
     <intent-filter>           
      <action android:name="android.provider.Telephony.SMS_RECEIVED" /> 
     </intent-filter> 
    </receiver> 
+0

如果我的包是一个问题,我不应该在日志中得到一个错误?我有另一个名为nz.co.view的包,如果我改变,可能冲突 – 2012-04-11 07:38:14

+0

看到我的更新.. – confucius 2012-04-11 07:41:38

+0

没有错误将出现在日志 – confucius 2012-04-11 07:44:16

相关问题