I come here because i really don't understand why i don't get the BroadcastReceiver I have a service called NotifService which creates notifications. i created a receiver following this code :
public class MyReceiver extends BroadcastReceiver {
Intent myIntent;
@Override
public void onReceive(Context context, Intent intent) {
Log.d("2erlog","2erlog>>>>>>>>>>>>>>>>>>>>>>>>");
myIntent = new Intent(context, NotifService.class);
context.startService(myIntent);
Log.d("3erlog","3erlog>>>>>>>>>>>>>>>>>>>>>>>>");
}
}
And here you can see my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notifplugunplug"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service android:name="NotifService"/>
<activity
android:name="com.example.notifplugunplug.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Declaring broadcast receiver for BOOT_COMPLETED event -->
<receiver android:name=".MyReceiver" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
I know that the service never start because i never see logs i created and i don't see notifications appear from the service.
Thank you guys !
The "android.intent.action.BOOT_COMPLETED" is a global broadcast.
Since you have defined your BroadcastReceiver as android:exported="false" it will get only local broadcast.
Change it to android:exported="true".