Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> 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> <p>here you are tying to access Ui elements TextView in doInBackground. so move this line in <code>onPostExecute</code> method of <code>AsyncTask</code> :</p> <p>remove runOnUiThread from doInBackground move all Ui elemets to onPostExecute .change your code as:</p> <pre><code>class GetProductDetails extends AsyncTask&lt;String, String, Arraylist&lt;String&gt;&gt; { /** * 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 Arraylist&lt;String&gt; doInBackground(String... params) { Arraylist&lt;String&gt; arraylist=new Arraylist&lt;String&gt;(); // Check for success tag int success; 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); // product with this pid found // display product data in EditText arraylist.add(TAG_LAT); arraylist.add(TAG_LONG); }else{ // product with pid not found } } catch (JSONException e) { e.printStackTrace(); } return arraylist; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(Arraylist&lt;String&gt; arraylist) { // dismiss the dialog once got all details // Edit Text //txtName = (EditText) findViewById(R.id.inputName); tvlat = (TextView)findViewById(R.id.tv_lat1); tvlong = (TextView)findViewById(R.id.tv_long1); tvlat.setText(product.getString(arraylist.get(0))); tvlong.setText(product.getString(arraylist.get(1))); pDialog.dismiss(); } } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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