Downloading a file after http-get and http-post.

by Robin van Leeuwen » Sun, 18 Jul 2010 20:24:43 GMT


Sponsored Links
 Hi there,

i am building an application which at some point sends a http-get to a
webserver and the webserver responds with a .zip file to download.
The same with a http-post. In a browser after clicking submit (post) or the
link (get)
it asks me where i should download the .zip file.

I want my android app to automatically download the file:
In the case of the post i build a name-value-pair and use execute the built
httppost:

 httppost.setEntity(new UrlEncodedFormEntity(nvp));
 HttpResponse httpresponse = httpclient.execute(httppost);
 HttpEntity entity = httpresponse.getEntity();

How can i download the .zip file with which the webserver responds.

Can someone point me in the right direction, or perhaps give me an example
how to download files in android?

Kind regards,

Robin van Leeuwen

--



Other Threads

1. XML schema validation Android

Hi,
        I have created an XML and i want to validate with schema i.e,
xsd file but there are no direct classes provided by android for the
same if i am not wrong ......... and there is an external jar named
jaxp1.3 which doesnt allow me to compile the code is it because the
bytecode of desktop and android are different?  which has the classes
schema factory and validator which does the validation stuff ......Is
there an other option available . Any help would be appreciated .....
desperately searching for the ans..........
--~--~---------~--~----~------------~-------~--~----~

2. OutOfMemoryError when changing screen orientation

Hi,

I get an OutOfMemoryError every time i change the screen orientation
and I am having a hard time finding the mistake...

The Activitie's view consists of an ImageView, two Buttons and a
Spinner. I don't have static variables and can't imagine where i could
leak a context.

Most of the times, the exception is thrown at setContentView
(R.layout.upload);
sometimes it goes fine until imgUpload.setImageURI(imageURI);

The images i am displaying are form the G1's camera, so about 500kb
and 2048x1536pixels

Here is some code:
-------------------------------------------------------------------------------------
        private ImageView imgUpload;
        private Spinner spnCollections;
        private Button btnEditMetadata;
        private Button btnUpload;
        private Uri imageURI;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.upload);

                // Get View References
                imgUpload = (ImageView) findViewById(R.id.imgUpload);
                spnCollections = (Spinner)findViewById(R.id.spnCollections);
                btnEditMetadata = (Button) findViewById(R.id.btnEditMetadata);
                btnUpload = (Button)findViewById(R.id.btnUpload);

                // Get Image from ACTION_SEND Intent
                Intent intent = getIntent();
                if (intent.getAction() != null && intent.getAction().equals
(Intent.ACTION_SEND)) {
                        Bundle extras = intent.getExtras();
                        imageURI = 
(Uri)extras.getParcelable(Intent.EXTRA_STREAM);
                        imgUpload.setImageURI(imageURI);
                }
...
-------------------------------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~

3. what do MACRO "LOCAL_SDK_VERSION " do?

4. what's "/sys/class/net/ppp0/operstate"? where can i find the source code about it?

5. KeyEvent.KEYCODE_ENDCALL doesn't work

6. How to show two or more fields to list(Notepad Tutorial)?

7. sales on android - how is that going??