Trying to start a service on boot on Android

The other answers look good, but I thought I’d wrap everything up into one complete answer. You need the following in your AndroidManifest.xml file: In your <manifest> element: <uses-permission android:name=”android.permission.RECEIVE_BOOT_COMPLETED” /> In your <application> element (be sure to use a fully-qualified [or relative] class name for your BroadcastReceiver): <receiver android:name=”com.example.MyBroadcastReceiver”> <intent-filter> <action android:name=”android.intent.action.BOOT_COMPLETED” /> </intent-filter> … Read more

Service Ended When I Kill App

You could do by do some changes to your CallDetectService class : @Override public int onStartCommand(Intent intent, int flags, int startId) { callHelper = new CallHelper(this); int res = super.onStartCommand(intent, flags, startId); callHelper.start(); return START_STICKY; } @Override public void onTaskRemoved(Intent rootIntent) { callHelper.start(); } @Override public void onDestroy() { super.onDestroy(); sendBroadcast(new Intent(“IWillStartAuto”)); // Toast.makeText(this, “Closed”, … Read more