Here I am going to explain how to open an image using URI in Android's default gallery image viewer
public void viewImage()
{
File file = new File(Environment.getExternalStorageDirectory()
+ "testimage.png");
if (file .exists())
{
Uri path = Uri.fromFile(file );
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path ,"image/*");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(pdfIntent ); }
catch (ActivityNotFoundException e)
{
Toast.makeText(EmptyBlindDocumentShow.this,"No Application available to view Image",
Toast.LENGTH_SHORT).show();
}
}
}
Happy Coding :)
public void viewImage()
{
File file = new File(Environment.getExternalStorageDirectory()
+ "testimage.png");
if (file .exists())
{
Uri path = Uri.fromFile(file );
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path ,"image/*");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(pdfIntent ); }
catch (ActivityNotFoundException e)
{
Toast.makeText(EmptyBlindDocumentShow.this,"No Application available to view Image",
Toast.LENGTH_SHORT).show();
}
}
}
Happy Coding :)
No comments:
Post a Comment