The code to start the service at bootup….. I have even included the permissions in the manifest file as mentioned before…but the service doesn’t start…i have to explicitly start as of now by startService(Intent..) commmand… Is there any mistake in what i have done??
public class BootReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent arg1) {
Intent serviceIntent = new Intent(BackgroundService.class.getName());
context.startService(serviceIntent);
}
}
<receiver android:name="BootReceiver">
<intent-filter>
<action
android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
You are using permissions in a wrong way. By setting permission in a receiver tag you are requesting such permission from broadcaster. But your applicationneeds this permission, not broadcaster. Declare permission in root of the manifest in ‘permission’ tag