I really tried it all, the broadcast receiver doesn't receive new incoming sms broadcasts. I'm running on my phone 4.4.4, I just want to listen to incoming messages, that is.
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name=".SmsReceiver"
android:enabled="true"
>
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED_ACTION" />
</intent-filter>
</receiver>
</application>
the broadcast receiver:
public class SmsReceiver extends BroadcastReceiver {
public SmsReceiver() {}
@Override
public void onReceive(Context context, Intent intent) {
Log.d("v", "SMS onReceive");
}
gradle:
android {
compileSdkVersion 20
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.dev.xxx"
minSdkVersion 19
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:+'
}
The <action>
you've defined in the <receiver>
's <intent-filter>
in the manifest is incorrect. It should be:
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
You might be confusing it with the class constant String identifier android.provider.Telephony.Sms.Intents.SMS_RECEIVED_ACTION
, which has the value shown above.