/* Return Drawable Object from Specified imageUrl In Web
@imageUrl : image Url in Web
*/
try {
/// Getting image from Web
InputStream is = (InputStream) new URL(imageUrl).getContent();
// storing image from stream
drawable = Drawable.createFromStream(is, "srcName");
is.close();
// converting drawable object to Bitmap to store in content providers of Media
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
// Store image in Devise database to send image to mail
String path = Images.Media.insertImage(getContentResolver(), bitmap,"title", null);
Uri screenshotUri = Uri.parse(path);
final Intent emailIntent1 = new Intent( android.content.Intent.ACTION_SEND);
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent1.setType("image/png");
startActivity(Intent.createChooser(emailIntent1, "Send email using"));
}
catch(Exception e) { }
No comments:
Post a Comment