0

I am developing a small android application in which I wanted to start some service once the device boot is completed.

This is the code I used to try to accomplish this, but it not receiving boot complete event, so it isn't working.

//in manifest file 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<receiver android:name="MyScheduleReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

//my schedule receiver 
public class MyScheduleReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent)
  {
      if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction()))
      {
         Log.i("*************************TEST", "Service loaded at start");
         Toast.makeText(context, "device started", Toast.LENGTH_SHORT).show();
      }
  }
} 

MyScheduleReceiver never gets triggered; am I doing something wrong?

Nightfirecat
  • 11,432
  • 6
  • 35
  • 51
nilkash
  • 7,408
  • 32
  • 99
  • 176

1 Answers1

2

You miss a dot before MyScheduleReceiver

<receiver android:name=".MyScheduleReceiver" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54