0

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" />
Arun Abraham
  • 4,011
  • 14
  • 54
  • 75

1 Answers1

0

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

Olegas
  • 10,349
  • 8
  • 51
  • 72
  • even that did not work for me.... outside the application node in the manifest... – Arun Abraham Apr 02 '11 at 05:34
  • Double-check yout code and manifest. Also look this question: http://stackoverflow.com/questions/1056570/how-to-autostart-an-android-application – Olegas Apr 03 '11 at 18:47