In my app I import gpx and kml files to display tracks and waypoints on the map. For this operation, I use about 5 methods. Everything works fine, unless I try to import several long gpx/kml tracks with exfilechoser. The screen goes black for some seconds, and logcat says: skipped frames ( > 600). How could I get these calculations of the UI? Or how could I use AsyncTask with about 5 methods? Is this possible?
-
Use AsyncTask it will run all process in the background and u have an onPostExecute method called when the work is done – thunder413 May 24 '16 at 12:47
-
You have to use the thread and I guess a good solution it would be using the asynctask as you wrote. Yes you can use 5 different asynctask, but remember that they will be asynchronous so you have to study how to handle the worked data. – michoprogrammer May 24 '16 at 12:49
-
That could be difficult (as they should do there computations aligned). Maybe I'll figure something out. Thank you for your reply! – stan210 May 24 '16 at 13:01
3 Answers
By looking at your question i will suggest you to use handler
with java normal multi threading concept
.
I dont think Asyntask
is a very good approach to do long running tasks on background.
It's good have do calculation on server side it reduces the overhead on mobile site.

- 3,201
- 37
- 66
There are several methods.
Do calculations asynchronously. Android SDK provides
Handler, IntentSevice, AsyncTask, HandlerThread
to solve problems asynchronously. By the way, it is recommanded to use multi-thread solving heavy calclations.Let server do calculations. Mobile devices is not suitable for calculating, calculations consume power and affect app performance.

- 90
- 1
- 7
I think you should use Service which was designed for this purpose. It is said in documentation:
A Service is an application component that can perform long-running operations in the background.
You should remember about creating new thread in service.
Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work.

- 948
- 9
- 27
-
Thank you for your reply! I already tried to solve this issue with a service. But the screen still goes black. I used Service. Or should I use IntentService? But if it should work, I'll try it again. – stan210 May 24 '16 at 13:16
-
Did you start thread? Service is executed in main thread by default. "Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work. " – Grzegorz Bielański May 24 '16 at 13:24