Hi I'm writing an android app which has to retrieve some infos from a website using webview and js, I figured out how to do that when app is opened, is there a way to get these infos when app is closed? Almost like whatsapp and gmail do...
Asked
Active
Viewed 259 times
2 Answers
1
You're not going to be able to use a WebView when the app isn't showing. What you can do is use a service, which runs in the background, there you can make requests to download data over the Internet.
More info http://developer.android.com/guide/components/services.html
Keep in mind that your standard service will run on your applications main thread, so you may need to provide threading for yourself.
To make your code trigger at a given time checkout alarms: http://www.vogella.com/tutorials/AndroidTaskScheduling/article.html
For non WebView web browsing consider: Use V8 JavaScript engine to execute JS lib without webview

Community
- 1
- 1

JohanShogun
- 2,956
- 21
- 30
-
Ohh... Because what my app does... Is opening a website, log in, click on one element and take what there is on the page... Is there a way ti do that without a webview? – Alessio Ragno Jul 19 '15 at 21:10
-
I suppose you could make use of some of the things mentioned here: http://stackoverflow.com/questions/19408245/use-v8-javascript-engine-to-execute-js-lib-without-webview but it will be a lot of work and error prone as you will have to navigate a website and websites are prone to changing how they work "under the hood" – JohanShogun Jul 19 '15 at 21:17
-
Remember to up vote and accept answer if it helped you – JohanShogun Jul 20 '15 at 11:46