安装成功了,但接收到短信为什么没有调用onReceive方法,
public class SMSBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("TEST", "hehe");//为什么打印信息?
Object[] pdus = (Object[]) intent.getExtras().get("pdus");
for(Object p : pdus){
byte[] pdu = (byte[]) p;
SmsMessage message = SmsMessage.createFromPdu(pdu);
String senderNumber = message.getOriginatingAddress();
if("5556".equals(senderNumber)){
abortBroadcast();//终止广播
}
清单文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.itcast.smslisteners"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name=".SMSBroadcastReceiver">
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
</manifest>
没看到什么问题,是不是包名这些,还有就是是不是被其他软件给拦截了之类的。
被软件拦截?