I am doing this with this code and it works for me:
public class AutoStarter extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { Intent serviceLauncher = new Intent(context, your.class); context.startService(serviceLauncher); } } }
for testing you can use this in your cmd
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
source share