Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Simply follow the undermentioned steps :</p> <p>Step(1) Initiate AsyncTask in onCreate();</p> <pre><code>new HttpAsyncTask().execute(); </code></pre> <p>Step(2) Your AsyncTask class</p> <pre><code>class HttpAsyncTask extends AsyncTask&lt;String, Void, String&gt; { @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); pDialog = new ProgressDialog(getParent()); pDialog.setMessage("Please wait ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } @Override protected String doInBackground(String... e) { // TODO Auto-generated method stub String eusername = " "; String epassword = " "; String myUrl = StaticVars.loginurl + eusername + "~" + epassword + "~android"; Log.d("login", myUrl); HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(myUrl); try { HttpResponse httpResponse = httpClient.execute(httpGet); System.out.println("httpResponse"); // use this httpresponse for // JSON Object..... InputStream inputStream = httpResponse.getEntity().getContent(); InputStreamReader inputStreamReader = new InputStreamReader( inputStream); BufferedReader bufferedReader = new BufferedReader( inputStreamReader); StringBuilder stringBuilder = new StringBuilder(); String bufferedStrChunk = null; while ((bufferedStrChunk = bufferedReader.readLine()) != null) { stringBuilder.append(bufferedStrChunk); } jsonString = stringBuilder.toString(); Log.i("login1", jsonString); return stringBuilder.toString(); } catch (ClientProtocolException cpe) { System.out.println("Exception generates caz of httpResponse :" + cpe); cpe.printStackTrace(); } catch (IOException ioe) { System.out .println("Second exception generates caz of httpResponse :" + ioe); ioe.printStackTrace(); //pDialog.dismiss(); System.out .println("Connection refused :" + ioe); } return null; } @SuppressWarnings("static-access") @Override protected void onPostExecute(String result) { // TODO Auto-generated method stub super.onPostExecute(result); pDialog.dismiss(); // Do whatever stuff u need to do } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload