Download a large sample of application data

I am developing a map rendering application for Android. The card data is quite large at around 1.1 GB. Since there are restrictions both in the market and in the phone for the .apk size, it is recommended to download it when the application starts.

This is the template I am using now:
1. The main activity (used to display the map) checks if data is available if I do not start the download

2. The download activity starts from the local service
3. The service downloads zip files and unpacks mapdata
4. The service sends download activity events and notifications

I start the service, as the whole process can take some time from 30 minutes to several hours depending on the phone and network.

But I have a problem with the fact that only one instance of the program works, I tried all combinations of the launchmode property without help.

As you understand, launching two instances will lead to failure of loading / unpacking.

This is really frustrating! Now I do some ugly read / write sdcard file locks, and it works most of the time to make sure that only one instance works.

I am targeting Android 1.6 and above.

+3
source share
2 answers

To avoid problems with multiple instances, you should use a remote service instead of a local service. Thus, you can have only one instance of the service that will load the data necessary for the application.

+1

1,1 - . Wi-Fi, , , , . , - , , , , ( ).

, , , , . , , , - . , - , , , / . , , .

, Android GC'd , , , , , , . , - , , . , .

SD-? , , , .

0

Source: https://habr.com/ru/post/1790698/


All Articles