的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.test"
android:versionCode="1"
android:versionName="1.0"
android:enabled="true"
android:exported="true"
android:label="@string/app_name">
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<receiver
android:name="com.android.test.receiver"
android:exported="true"
android:enabled="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="2147483647" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
receiver.java
package com.android.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class receiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Received!", Toast.LENGTH_LONG).show();
}
}
一步一步:
telnet localhost 5554
sms send 01 test
我的问题:为什么?当我创建MainActivity并打开APP窗口时,我的APP会收到有关“SMS_RECEIVED”操作的回调: - /