Created
July 20, 2016 09:35
-
-
Save webserveis/2a03f1f34dcfd2a23cd3f789295c3bf1 to your computer and use it in GitHub Desktop.
Launch file chooser selector dialog
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 static final int FILE_CHOOSER = 100; | |
... | |
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | |
intent.setType("*/*"); | |
startActivityForResult(Intent.createChooser(intent, "Choose File"), FILE_CHOOSER); |
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
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
switch (requestCode) { | |
case FILE_CHOOSER: | |
Log.d(TAG, "onActivityResult: FILE_CHOOSER =" + FILE_CHOOSER); | |
if (resultCode == RESULT_OK) { | |
Uri uri = data.getData(); //obtener el uri content | |
Log.d(TAG, "uri: " + uri.toString()); | |
} else { | |
//if (resultCode == RESULT_CANCELED) { | |
Log.w(TAG, "Cancel by user"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment