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
Related
I am trying to create an app in which i am using background serviced plugin for uploading data to server.Then i tried to go back to the app home page when a background service will start so the user can do other work while data is uploaded. but the issue is as soon as I click on the device back button it gives an network not found error and background service stops and it navigate to another page. Then i search how to navigate to device main page using device back button using home plugin know after starting the background service when i click on the back button it opens the device home-screen and the backgroung process continues. Can anyone tell me how to make an background serviced continue and navigate to another page.
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?
I'm working now in a project to download images from the web and then show it after completing its download.
i made an activity class that has a button and text field and when the user press on the button, i started a service which will show a notification in status bar and after download i will show a message .
my main problem now is i want to go to other application or home page while the download is working.
i tried it but i after the download i got the message ,,, " Force quit"
should i use broadcast receiver or remote server to handle what i want.
Thanks,
The service should be the one downloading the content. If you go to the home activity our activity calls onPause, stoping all the work in progress.
Activities are just that, activities, they only work when visible and are built strictly for user interaction or a user activity, so this is impossible. Use a service instead. Here is a diagram showing lifespan of an activity:
Link to App activity explanation on Android developer site
You may need to call Looper.Loop() in your service to keep it running if you have any listeners in your service.
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.
basically, what am doing is that am running a flash file (playing music) in the background of the app using webview, and when I want to stop the music , I just load "about:blank"
I want to keep the flash file running (music) when my app gets paused (which works fine so far) the problem is when the app resumes, pressing on pause button launches a new webview instead of changing the link in the previous one and the sound doesn't stop
the only solution I found was to kill the process and restart the app, but that's not practical, any idea of how to still be able to use the same webview when resuming the app ?
Update: guess I wasn't clear enough, I have a webview widget stated as "gone" , I only need the audio form the flash file I'm running in the webview so the "play" button loads a URL that contains the flash file (so the user only hears music, and doesn't notice that I'm using a webview), when I press the back/home button the music doesn't stop (I like it that way) but when I go back and press on play again it loads another url in a new page, you get double music
There are a few possible causes for this. One is simply that multiple instances of your activity are being created. Assuming you don't want this, add android:launchMode="singleTask" or android:launchMode="singleInstance" to your main <activity> in AndroidManifest.xml. More info here:
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
If that doesn't help, another possibility is that your application is creating a new instance of the WebView -- either because the relevant code is in the wrong place (e.g. onStart()), or because the app has actually been destroyed and re-created by Android rather than paused and resumed -- and the old WebView thread is still hanging around for some reason. More information (such as code samples) would be helpful in identifying the problem, if that's the case.
Not sure about this solution but at least you should try this once
protected void onResume() {
super.onResume();
activityTermsAndConditionBinding.webView.releasePointerCapture();
activityTermsAndConditionBinding.webView.invalidate();
}