Return to Snippet

Revision: 41757
at February 23, 2011 03:24 by BenClayton


Updated Code
// DOWNLOAD THE PROJECT JSON FILE
		HttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet(url);

            Log.d(TAG, "executing request " + httpget.getURI());

            // Create a response handler
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = httpclient.execute(httpget, responseHandler);
            
            //
            Log.i(TAG, "DOWNLOADED " + responseBody);

        } catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
            // When HttpClient instance is no longer needed,
            // shut down the connection manager to ensure
            // immediate deallocation of all system resources
            httpclient.getConnectionManager().shutdown();
        }

Revision: 41756
at February 23, 2011 03:24 by BenClayton


Initial Code
// DOWNLOAD THE PROJECT JSON FILE
		HttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet(projectDirectoryUrl + "/project.json");

            Log.d(TAG, "executing request " + httpget.getURI());

            // Create a response handler
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            String responseBody = httpclient.execute(httpget, responseHandler);
            
            //
            Log.i(TAG, "DOWNLOADED " + responseBody);

        } catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
            // When HttpClient instance is no longer needed,
            // shut down the connection manager to ensure
            // immediate deallocation of all system resources
            httpclient.getConnectionManager().shutdown();
        }

Initial URL

                                

Initial Description

                                

Initial Title
Android: Download a string from a url

Initial Tags

                                

Initial Language
Java