Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually I have already applied the AsyncTask but I did it wrongly. Selvin pointed out that I move 'getJSONfromURL' call into doInBackground. And it works!</p> <pre><code>class GetPayPalResult extends AsyncTask&lt;String, String, String&gt; { ListActivity theList = new ListActivity(); private ListView mainListView ; private ProgressDialog pDialog; /* * * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(CheckOut.this); pDialog.setMessage("Loading Options ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /* * * getting Inbox JSON * */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("payKey", payKey)); params.add(new BasicNameValuePair("requestEnvelope.errorLanguage", "en_US")); httppost.setHeader("X-PAYPAL-SECURITY-USERID", "66.whatever.com"); httppost.setHeader("X-PAYPAL-SECURITY-PASSWORD", "6666666"); httppost.setHeader("X-PAYPAL-SECURITY-SIGNATURE", "55546g"); httppost.setHeader("X-PAYPAL-APPLICATION-ID", "APP-80W284485P519543T"); httppost.setHeader("X-PAYPAL-REQUEST-DATA-FORMAT", "NV"); httppost.setHeader("X-PAYPAL-RESPONSE-DATA-FORMAT", "NV"); String result = getJSONfromURL(paypalkeyurl,params); Log.d("Paykey Content: ", result); return null; } /* * * After completing background task Dismiss the progress dialog * * */ protected void onPostExecute(String file_url) { pDialog.dismiss(); } public String getJSONfromURL(String url, List&lt;NameValuePair&gt; params) { InputStream is = null; String result = ""; //Toast.makeText(CouponView.this,"running this", Toast.LENGTH_LONG).show(); // http post try { HttpPost httppost = new HttpPost(url); httppost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); HttpResponse response = Client.getInstance().execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e("log_tag", "Error in http connection :" + e.toString()); } // convert response to string try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } return result; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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