Origin Needs To Download Files And Is Waiting For Permission

«YOUR DOWNLOAD HAS BEEN PAUSED. Origin needs to download files and is waiting for permission. Please choose 'Yes' when Windows prompts you for permission. When prompted, grant permission within the user account control pop-up. 2) Origin needs to download files and is waiting for permission. Please choose Yes when Windows prompts you for permission'.

Hi Friends,

I have a new Windows 7 laptop (64 bit), and struggling at times to learn how to use it. I'm in the habit on my Windows XP desktop, of downloading setup/installer files into Program Files, where I set things up as follows:

Program Files

--Adobe

--Games

----Tetris

------Tetris program

------Tetris installer

--Inkscape

----Inkscape program

----Inkscape installer

----Inkscape tutorial #1

Sorry, I can't figure out how to make a single-space. Hopefully you can see that I put my setup/installer file in its own folder, alongside the program folder, both within what I guess you could call an 'umbrella folder'. For example you can see that I might also put a tutorial or some other related item -- I'm very organized. So when I download, I would put the setup/installer or zip file into 'Inkscape installer' or 'Tetris installer'. Then when I install or unzip, I do so into 'Inkscape program' or 'Tetris program'. That's how I do it on my XP desktop computer, and have been for years. But here in Windows 7, when I try to download into Program Files, I get an error message:

'You don't have permission to save in this location. Contact the administrator to obtain permission.' I AM the adiminstrator, my user account is the only one on this computer, and it's the adminstrator account!

After spending hours (5 or 6) with Dell tech support, finally I am told that in Windows 7, manual download directly into Program Files is not allowed. Files can only be installed directly or moved in after downloading elsewhere. I was ready to accept that and create a new sort of workflow for myself, perhaps keeping my installer files all in one folder, outside of Program Files. But then, while searching these forums, I came across this thread: http://social.answers.microsoft.com/Forums/en-US/w7files/thread/d2bb7c3c-bf0b-4ea6-8463-42461a56c105 It offers instructions for changing permissions. And I think I can probably follow those instructions without further help. But just before I did, I thought I should ask whether that applies to my particular problem, that I detailed above, including error message.

Have I been misinformed by Dell (it wouldn't be the 1st time). By following those instructions, will I be able to download in my usual manner? Or at the very least, can I try it relatively safely, without major complications?

I suspect that even if it doesn't solve my problem, it may reduce all the other permission related message boxes that keep popping up -- moving files around, etc. I hope so anyway.

Thanks for you help and attention. I really appreciate it :-)

Brynn

I am trying to write a simple application that gets updated. For this I need a simple function that can download a file and show the current progress in a ProgressDialog. I know how to do the ProgressDialog, but I'm not sure how to display the current progress and how to download the file in the first place.

Tom LeeseTom Leese
Origin needs to download files and is waiting for permission to play

12 Answers

There are many ways to download files. Following I will post most common ways; it is up to you to decide which method is better for your app.

This method will allow you to execute some background processes and update the UI at the same time (in this case, we'll update a progress bar).

This is an example code:

The AsyncTask will look like this:

The method above (doInBackground) runs always on a background thread. You shouldn't do any UI tasks there. On the other hand, the onProgressUpdate and onPreExecute run on the UI thread, so there you can change the progress bar:

For this to run, you need the WAKE_LOCK permission.

The big question here is: how do I update my activity from a service?. In the next example we are going to use two classes you may not be aware of: ResultReceiver and IntentService. ResultReceiver is the one that will allow us to update our thread from a service; IntentService is a subclass of Service which spawns a thread to do background work from there (you should know that a Service runs actually in the same thread of your app; when you extends Service, you must manually spawn new threads to run CPU blocking operations).

Download service can look like this:

Add the service to your manifest:

And the activity will look like this:

Here is were ResultReceiver comes to play:

2.1 Use Groundy library

Groundy is a library that basically helps you run pieces of code in a background service, and it is based on the ResultReceiver concept shown above. This library is deprecated at the moment. This is how the whole code would look like:

The activity where you are showing the dialog...

A GroundyTask implementation used by Groundy to download the file and show the progress:

And just add this to the manifest:

It couldn't be easier I think. Just grab the latest jar from Github and you are ready to go. Keep in mind that Groundy's main purpose is to make calls to external REST apis in a background service and post results to the UI with easily. If you are doing something like that in your app, it could be really useful.

2.2 Use https://github.com/koush/ion

GingerBread brought a new feature, DownloadManager, which allows you to download files easily and delegate the hard work of handling threads, streams, etc. to the system.

First, let's see a utility method:

Method's name explains it all. Once you are sure DownloadManager is available, you can do something like this:

Download progress will be showing in the notification bar.

First and second methods are just the tip of the iceberg. There are lots of things you have to keep in mind if you want your app to be robust. Here is a brief list:

  • You must check whether user has an internet connection available
  • Make sure you have the right permissions (INTERNET and WRITE_EXTERNAL_STORAGE); also ACCESS_NETWORK_STATE if you want to check internet availability.
  • Make sure the directory were you are going to download files exist and has write permissions.
  • If download is too big you may want to implement a way to resume the download if previous attempts failed.
  • Users will be grateful if you allow them to interrupt the download.

Unless you need detailed control of the download process, then consider using DownloadManager (3) because it already handles most of the items listed above.

But also consider that your needs may change. For example, DownloadManagerdoes no response caching. It will blindly download the same big file multiple times. There's no easy way to fix it after the fact. Where if you start with a basic HttpURLConnection (1, 2), then all you need is to add an HttpResponseCache. So the initial effort of learning the basic, standard tools can be a good investment.

This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress. For more details Link


Don't forget to add permissions to your manifest file if you're gonna be downloading stuff from the internet!

MnightmareMnightmare

Yes the code above will work .But if you are updating your progressbar in onProgressUpdate of Asynctask and you press back button or finish your activity AsyncTask looses its track with your UI .And when you go back to your activity, even if download is running in background you will see no update on progressbar. So on OnResume() try to run a thread like runOnUIThread with a timer task that updates ur progressbar with values updating from the AsyncTask running background.

Don't forget to Destroy the thread when ur activity is not visible.

sheetalsheetal

I'd recommend you to use my Project Netroid, It's based on Volley. I have added some features to it such as multi-events callback, file download management. This could be of some help.

VinceStylingVinceStyling

Origin

I have modified AsyncTask class to handle creation of progressDialog at the same context .I think following code will be more reusable.(it can be called from any activity just pass context,target File,dialog message)

The SyrianThe Syrian

I found this blog post very helpful, Its using loopJ to download file, it has only one Simple function, will be helpful to some new android guys.

chintan adatiyachintan adatiya

Do not forget to replace '/sdcard...' by new File('/mnt/sdcard/...') otherwise you will get a FileNotFoundException

ENSATEENSATE

While I was starting to learn android development, I had learnt that ProgressDialog is the way to go. There is the setProgress method of ProgressDialog which can be invoked to update the progress level as the file gets downloaded.

The best I have seen in many apps is that they customize this progress dialog's attributes to give a better look and feel to the progress dialog than the stock version. Good to keeping the user engaged with some animation of like frog, elephant or cute cats/puppies. Any animation with in the progress dialog attracts users and they don't feel like being kept waiting for long.

Bhargav Rao
SandeepSandeep

My personal advice is to use Progress Dialog and build up before execution , or initiate at OnPreExecute() , publish progress often if you use horizontal style of progress bar of the progress dialog. The remaining part is to optimize the algorithm of doInBackground.

Raju yourPepeRaju yourPepe

Origin Needs To Download Files And Is Waiting For Permission Free

Use Android Query library, very cool indeed.You can change it to use ProgressDialog as you see in other examples, this one will show progress view from your layout and hide it after completion.

RenetikRenetik
vishnuc156vishnuc156

I am adding another answer for other solution I am using now because Android Query is so big and unmaintained to stay healthy. So i moved to this https://github.com/amitshekhariitbhu/Fast-Android-Networking.

RenetikRenetik

protected by Hans OlssonDec 7 '11 at 11:13

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged javaandroiddownloadandroid-asynctask or ask your own question.