Android <receiver> - BroadcastReceiver not called

I specified the recipient in the manifest like this:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.me.MyProject" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.RECEIVE_SMS"/> <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:enabled="true"> <service android:name="MyService" android:exported="true" android:process=":different" android:enabled="true"> <intent-filter> <action android:name="com.me.MyService"> </action> </intent-filter> </service> <receiver android:exported="true" android:name="MySMSBroadcastReceiver" android:enabled="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED"/> </intent-filter> </receiver> </application> 

If I test this on an Android Froyo device (emulator or real), it works as I expect. MySMSBroadcastReceiver.onReceive (...) is called when the device receives SMS.

However, if I install this on a 4.0 or 4.1 device (either in an emulator or in a real device), nothing happens in the incoming message. No mistakes, nothing. I also changed the properties for the project, specifically designed for the device 4.0 or 4.1, and reinstalled it, but it does not matter.

+4
source share
2 answers

After your application is installed, the user needs to start his activity manually before any of your BroadcastReceivers will have an effect on Android 3.1 .

+5
source

You can start the receiver at OS startup by specifying the correct permissions.

0
source

Source: https://habr.com/ru/post/1432449/


All Articles