Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading an image which's path is stored in a mysql database in android
    primarykey
    data
    text
    <p>I want to load an image from web which's path is stored in a MySQL database in android. I have been trying for long. but the code never seem to be working. please help. it's for my academic project.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads().detectDiskWrites().detectNetwork() // StrictMode is most commonly used to catch accidental disk or network access on the application's main thread .penaltyLog().build()); super.onCreate(savedInstanceState); setContentView(R.layout.details); Intent i=getIntent(); pid=i.getStringExtra(TAG_PID); new GetProductDetails().execute(); new GetImageUrl().execute(); int loader = R.drawable.loader; ImageView image = (ImageView) findViewById(R.id.imageView1); ImageLoader imgLoader = new ImageLoader(getApplicationContext()); new GetImageUrl().execute(); url1="http://neogdgt.com/"+url; imgLoader.DisplayImage(url, loader, image); } </code></pre> <p>and here is the code for getting the path</p> <p>class GetImageUrl extends AsyncTask {</p> <pre><code> /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(Details.this); pDialog.setMessage("Loading product image. 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 runOnUiThread(new Runnable() { public void run() { int success; try { List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("pid", pid)); JSONObject json = jsonParser.makeHttpRequest( url_product_detials, "GET", params); Log.d("Single Product Details", json.toString()); success = json.getInt(TAG_SUCCESS); if (success == 1) { JSONArray productObj = json .getJSONArray(TAG_add); int a = Integer.parseInt(pid); JSONObject product = productObj.getJSONObject(0); url = product.getString(TAG_URL); }else{ } } catch (JSONException e) { e.printStackTrace(); } } }); return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { pDialog.dismiss(); } } </code></pre>
    singulars
    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.
    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