public class MyService extends Service {
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.e("Service", "Running");
return Service.START_STICKY;
}
}
My service is killed and didn't restart after task kill in vivo phones. But, Facebook app restart it's service in my phone. Why? public class StartMyServiceAtBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent myService = new Intent(context, MyService.class);
context.startService(myService);
}
else if(Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
Intent myService = new Intent(context, MyService.class);
context.startService(myService);
}
}
} I start my service by using receiver..