开发者

Can't get broadcastreceive from incoming message

开发者 https://www.devze.com 2023-02-16 17:00 出处:网络
I have a BroadcastReceiver declared in the following AndroidManifest.xml, but I never get the SMS_RECEIVED broadcast. Any ideas what is happening?

I have a BroadcastReceiver declared in the following AndroidManifest.xml, but I never get the SMS_RECEIVED broadcast. Any ideas what is happening?

This is the BroadcastReceiver:

public class SMSReceiver1 extends BroadcastReceiver 
{ 
    private static final String LOG_TAG = "Thiri The Wut Yee";

    private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";

    public voi开发者_JS百科d onReceive(Context context, Intent intent) 
    {
        Log.i(LOG_TAG, "Receive ");
        Toast.makeText(context, "RECEIVED", Toast.LENGTH_LONG).show();
    }
}

And the AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="android_programmers_guide.SMSReceiver1"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <receiver android:name=".SMSReceiver1"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
            </intent-filter>
       </receiver>
    </application>
    <uses-sdk android:minSdkVersion="4" />
</manifest> 


Do you have this permission in your manifest?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消