Android always run application in background even force killed
Create a service:
public class YourService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { // do your jobs here return super.onStartCommand(intent, flags, startId); } }
Create an Application class and start your service:
public class App extends Application { @Override public void onCreate() { super.onCreate(); startService(new Intent(this, YourService.class)); } }
Don’t forget add this in “application” tag of your AndroidManifest.xml
android:name=".App"