How to Download Images and video from server before application start - android

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.

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

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.

Related

File upload fails when phone screen turns off

In my web app, when submitting a form with a file to be uploaded, if the user pushes the button to turn the screen off before the upload finishes, it doesn't get uploaded. I'm assuming this is because the browser has been put into the background to sleep. I've searched for the answer here for how to approach this problem, but haven't found anything for a web app. Is there a way to keep the browser awake in the background until the file upload finishes, or a way to detect when the browser sleeps and then wakes up, or should I just show the user a message to Please Wait and hope they don't shut the screen off?
I didn't receive any responses. What I ended up doing is just showing a "Uploading..." message with a spinning loader. I'll update my post if I find a better way to handle this.

Receive a callback when third-party app successfully loaded the file in android

Is there a way to know if the third-party app successfully loaded the file?
My app has a user manual which is in pdf. When user taps the link to open it, my app calls for another app to open the file (implicit intent). The problem is, sometimes the 3rd-party app lags 2-5 secs before showing the pdf.
Now, what I want is to show a loading dialog in my app while the 3rd-party app is loading the pdf in the background and once the pdf is successfully loaded, receive a callback from the 3rd-party app to finish the loading dialog and show the user manual.
Is it possible? Thanks in advance :)
Create a ContentProvider within your app which serves the PDF file. You could then use a local broadcast or an event bus to have the content provider notify you when it's done serving the requested file. As your third-party viewer-app likely won't request the file until it's done initializing, you should get an event close to when your file is being displayed.
The moment you call an Intent to start an activity of another app, you couldn't interact with your app (activity, fragment) anymore, so I think it's not feasible.

What should I do when the android activity is interrupted?

I currently have a program where a user fills information out and sends it to a server. It then downloads a one to two MB file to device. I have it setup so the phone does not sleep when it is downloading the file, but it is interrupted when the user manually presses the sleep button or a text comes in to the phone. What would be the best solution to this? Should I create a service or is there someway to tell the activity to keep downloading in the onPause method?
won't it be better to download in the background using an android service and posting an android notification when it will be done?

Download video from AmazonS3 with ProgressBar in Android

Here i developed one application which download big size of videos from AmazonS3Bundle with HorizontalProgressBar but when i go to home screen by pressing home key and when i get back to my application's download screen, my download is restarting from beggining.
I want my application to keep downloading in background even if i go to any other application.
That's because your Activity's onCreate() gets called everytime and the task to Download gets started again.
You should make one Service class to do the download task, So it will keep doing it in Background irrespect of the state of the Application.
Check these two examples : first and second link

Android - How would you go about installing setup data from the internet

I am working on an android application that uses data from the internet. On first use, downloading and inserting data into the database takes a some time which might make the user feel that the application is non-responsive and might drive impatient users away immediatly. I am currently displaying a progress dialog to inform the user that this operation might take some time to complete (around 1/2 a minute).
is there a way to install all the data while installing the application, ie. before first use?
No. You cannot do this. Other applications can capture Intent after an app is downloaded, but not if it is the app that was just downloaded.
This question is similar to Launch a service after the intallation of my Android application.

Categories

Resources