Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get size of selected image in bytes
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
You can’t perform that action at this time.