Salve, ho eseguito questa guida per creare un processo in background.
http://blog.rhesoft.com/2016/03/14/t...ndroid-studio/
per eseguire un servizio in background si fà in questo modo?
codice:
@Override
public void onCreate() {
// To avoid cpu-blocking, we create a background handler to run our service
HandlerThread thread = new HandlerThread("TutorialService",
Process.THREAD_PRIORITY_BACKGROUND);
// start the new handler thread
thread.start();
mServiceLooper = thread.getLooper();
// start the service using the background handler
mServiceHandler = new ServiceHandler(mServiceLooper);
}
il servizio del processo la attivo in questo modo in Mainactivity , però quando la chiudo l'app il processo viene chiuso.
codice:
TutorialService rec2=new TutorialService();
rec2.onCreate();