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?
Related
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.
Im wondering if there is a way in android to run tasks in the background by just using the android packages without using AsyncTask. What i imagine is a background task which is still running when the Activity is already finished or the app already got closed. I want the user to see the progress of this task in the notification tab of android (the tab you can swipe down from the top of the android screen).
I want to do this for example when i send e-mails or when i send data like images to the server. because they are quite long running tasks i dont want the user to wait for them to finish. i want them to run in the background so that the user can close the app. and i want the user to see the progress in the notification bar.
Also i would like to know if there is a way to automatically repeat such a background task when it failed because the device did not have connection to the internet.
Im looking forward to read the answers and to learn something new.
You must use service.
I think these links can help you to use it:
http://developer.android.com/training/run-background-service/index.html
http://inchoo.net/dev-talk/android-development/android-simple-service/
Download a file with Android, and showing the progress in a ProgressDialog
Example: Communication between Activity and Service using Messaging
I'm facing the following problem. I want to make an android device to run only my application. All other apps and phone feautes should not be available to a user.
The reason why I want to achieve this is simple: I want to destribute devices with preinstalled application to my client but I don't want to let them use all phone featues.
This could work this way: just after android boots my application is launched automatically and than somehow all other staff is blocked.
Do you have any suggestions how to achieve that? Is it possible? Do I need to root a device?
I hope you get my problem. Any advice you can give will be greatly appreciated.
This is a bit crude way. But see if it is of any help.
If you create your application as a launcher it will start on boot(using system broadcast BOOT_COMPLETED).
Then you need to override all the three android buttons Home, back and recent apps.
To override back button you just have to override the onBackPressed() method.
For home button you will start a service which will run in background. This service will check if your app is in foreground or not. if not then it will bring it in foreground. so when the user presses home the service will sense the foreground app isnt yours and launch it.
But for this switching back of your app android takes approx 3 to 5sec. In that period of time you can display a warning text which will block the user from stopping the service from settings.Also if you remove the activity animations then it will appear seamless.
For recent apps button the above trick will do. If the user tries to close the app using this button your background service will sense it and launch your app.
so its the background service that does all the trick. if you some how stop the service or uninstall the app you are through :p
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.
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.