I know this is a question that is asked a lot on here, but I have the most barebones implementation of an SMS BroadcastReceiver in my Android maps app and it will not fire no matter what I've tried. I just wiped my phone, so no other apps should interfere with the receiver. In fact, I tried my friend's app who uses the same feature, but his implementation worked and my did not, despite the code being almost exactly the same. I know it's a shot in the dark, but I was wondering if you might happen to know why the following code is not executing.
AndroidManifest.xml
<uses-feature android:name="android.hardware.telephony" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
SMSReceiver
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("msg", "called");
}
}
The minimum SDK is 18 and the target is 23. Thanks for all your help!