Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot use the method <code>runOnUiThread</code> <strong>inside</strong> <code>doInBackground</code>... the part that modifies the ui should be moved to <code>onPostExecute</code>..</p> <p>it should be..</p> <pre><code>class GetProductDetails extends AsyncTask&lt;String, String, String&gt; { int success; /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(MapSimple.this); pDialog.setMessage("Loading location details. Please wait..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } /** * Getting product details in background thread * */ protected String doInBackground(String... params) { // updating UI from Background Thread try { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); //params.add(new BasicNameValuePair("pid", pid)); // getting product details by making HTTP request // Note that product details url will use GET request JSONObject json = jsonParser.makeHttpRequest( url_product_detials, "GET", params); // check your log for json response Log.d("Single Product Details", json.toString()); // json success tag success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully received product details JSONArray productObj = json .getJSONArray(TAG_LOCATION); // JSON Array // get first product object from JSON Array JSONObject product = productObj.getJSONObject(0); }else{ // product with pid not found } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog once got all details pDialog.dismiss(); if (success == 1) {// product with this pid found // Edit Text //txtName = (EditText) findViewById(R.id.inputName); tvlat = (TextView)findViewById(R.id.tv_lat1); tvlong = (TextView)findViewById(R.id.tv_long1); // display product data in EditText tvlat.setText(product.getString(TAG_LAT)); tvlong.setText(product.getString(TAG_LONG)); } } } </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.
    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