In my app I have only the activity "Main". There are quite a few subroutines. I would like to take some of them out to make the coding easier to read. The subs I want to take out would then make something similar to a service I think.
My idea would be to pass two parameters to this "service", allow the "service" to run, calculate and insert its results into a global list-variable in "Main".
My understanding is that there can be no interaction from the service with the activity whilst running. This is a problem, as this "Service" needs to interact with a webview (which is currently hidden in "Main"). No view is seen when the "service" runs but I would like the main-activity to be visible at all times. Theoretically I can move the subs to a second activity but there is nothing I want the user to see and then main is not visible.
The function of the "service" would be:
1. create an URL
2. Send URL to a website (which is running javascript)
3. Wait for webpage_loaded. Start a timer and wait for the website to finish calculations.
4. Get the data from the website.
5. Collect data from website and give data back to Main.
The website is not mine, I am injecting javascript into the webview to control the different function.
I hope this is clear.
I have read everything I can find but am still confused. Can someone point me in the right direction?
Many thanks.
My idea would be to pass two parameters to this "service", allow the "service" to run, calculate and insert its results into a global list-variable in "Main".
My understanding is that there can be no interaction from the service with the activity whilst running. This is a problem, as this "Service" needs to interact with a webview (which is currently hidden in "Main"). No view is seen when the "service" runs but I would like the main-activity to be visible at all times. Theoretically I can move the subs to a second activity but there is nothing I want the user to see and then main is not visible.
The function of the "service" would be:
1. create an URL
2. Send URL to a website (which is running javascript)
3. Wait for webpage_loaded. Start a timer and wait for the website to finish calculations.
4. Get the data from the website.
5. Collect data from website and give data back to Main.
The website is not mine, I am injecting javascript into the webview to control the different function.
I hope this is clear.
I have read everything I can find but am still confused. Can someone point me in the right direction?
Many thanks.
Last edited: