Created
March 7, 2017 06:33
-
-
Save bansalayush/fd5a298e61b7feb283c1322546aadd4c to your computer and use it in GitHub Desktop.
Get size of selected image in bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void showFileChooser() { | |
Intent intent = new Intent(); | |
intent.setType("image/*"); | |
intent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult(Intent.createChooser(intent, "Select Picture"), 2); | |
} | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if (requestCode == 2 && resultCode == RESULT_OK) | |
{ | |
String path = data.getData().toString(); | |
try { | |
f = new File(new URI(path)); | |
} catch (URISyntaxException e) { | |
e.printStackTrace(); | |
} | |
System.out.println("File size in bytes"+f.length()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment