I am trying to achieve Web Scraping through a background IntentService that periodically scrape a website without a view displaying on the users phone.
the solution was like this, but with Looper.getMainLooper() :
https://github.com/JonasCz/save-for-offline/blob/master/app/src/main/java/jonas/tool/saveForOffline/ScreenshotService.java
@Override
public void onCreate() {
super.onCreate();
//HandlerThread thread = new HandlerThread("ScreenshotService", Process.THREAD_PRIORITY_BACKGROUND);
//thread.start();
//mServiceHandler = new ServiceHandler(thread.getLooper()); // not working
mServiceHandler = new ServiceHandler(Looper.getMainLooper()); // working
}
with help of @JonasCz : https://stackoverflow.com/a/28234761/466363