Mitesh Jain
Mitesh Jain

Reputation: 673

How to Download Images and video from server before application start

My application size is more than 120 MB. it's content lots of images and Videos. so that i want to download all images and videos 1st in SD cards and after that my application start. This procedure work when i install application in device. after downloading all images and videos My application start. Thanks In Advance.

Upvotes: 0

Views: 538

Answers (2)

Rahul Choudhary
Rahul Choudhary

Reputation: 3809

  1. Create a service to download the content from the server.
  2. Add your activity to it for custom event listening
  3. Broadcast event [Completion, Part-Completion] to the registered listener when the service is able to do the job.
  4. Till that time either show a splash screen or a download screen with progress bar indicating download progress.
  5. On listening to "Completion" notification you can show the main activity.

Hope this helps

Upvotes: 2

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72331

You should make a Splash Activity for your application. So this will be an Activity that displays only a picture, let say your application logo or something similar. Then check if your app has all ready downloaded the videos and photos, you can do this by keeping a boolean field in SharedPreferences let say DATA_DOWNLOADED. If the data is not downloaded then you will need to start s Service that will download all the data, also display a ProgressIndicator and a message for the user, that data is being downloaded.

Once the data is downloaded you mark the DATA_DOWNLOADED field in your SharedPreferences and you start the next Activity.

Good luck.

Upvotes: 1

Related Questions