I want to convert bitmap to URI conversion I am using google image search API from this API I got image URL from this URL I converted it to a bitmap then I want to convert from this bitmap to URI using this sample but I get a null value.
private class GetXMLTask extends AsyncTask<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { Bitmap map = null; for (String url : urls) { map = downloadImage(url); } return map; } // Sets the Bitmap returned by doInBackground @Override protected void onPostExecute(Bitmap result) { imagQest.setImageBitmap(result); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); result.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = Images.Media.insertImage(ctx.getContentResolver(), result, "Title", null); LivLog.info(this.getClass(), "bit map conversion is" + result + path); } // Creates Bitmap from InputStream and returns it private Bitmap downloadImage(String url) { Bitmap bitmap = null; InputStream stream = null; BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inSampleSize = 1; try { stream = getHttpConnection(url); bitmap = BitmapFactory.decodeStream(stream, null, bmOptions); // stream.close(); } catch (IOException e1) { e1.printStackTrace(); } return bitmap; } // Makes HttpURLConnection and returns InputStream private InputStream getHttpConnection(String urlString) throws IOException { InputStream stream = null; URL url = new URL(urlString); URLConnection connection = url.openConnection(); try { HttpURLConnection httpConnection = (HttpURLConnection) connection; httpConnection.setRequestMethod("GET"); httpConnection.connect(); if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { stream = httpConnection.getInputStream(); } } catch (Exception ex) { ex.printStackTrace(); } return stream; } } How to resolve this?