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", Toast.LENGTH_SHORT).show();
    callHelper.start();
}

Browse More Popular Posts

Leave a Comment