2011-03-11 38 views
1

我在以下AndroidManifest.xml中聲明BroadcastReceiver,但我從來沒有收到SMS_RECEIVED廣播。任何想法發生了什麼?無法從傳入消息中獲得廣播接收

這是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 void onReceive(Context context, Intent intent) 
    { 
     Log.i(LOG_TAG, "Receive "); 
     Toast.makeText(context, "RECEIVED", Toast.LENGTH_LONG).show(); 
    } 
} 

而且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> 

回答

1

你有你的清單此權限嗎?

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

+0

邑,但SMS_RECEIVED – Renegade

+0

我不明白您的評論。 –

+0

Renegade