Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- botonExplorar.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
- // Filter to only show results that can be "opened", such as a
- // file (as opposed to a list of contacts or timezones)
- intent.setType("text/plain");
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- // it would be "*/*".
- //startActivityForResult(intent, READ_REQUEST_CODE);
- startActivityForResult(intent, EDIT_REQUEST_CODE);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
- });
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == Activity.RESULT_OK) {
- textInfo1.setText("");
- textInfo2.setText("");
- Uri mediaUri = data.getData();
- String mediaPath = mediaUri.getPath();
- textInfo2.setText(mediaPath);
- String selectedImagePath;
- //MEDIA GALLERY
- selectedImagePath = PathUtils.getPath(getApplicationContext(), mediaUri) ;
- Log.i("Image File Path", ""+selectedImagePath);
- textInfo2.setText(selectedImagePath);
- textInfo1.setText(mediaUri.toString());
- //Toast.makeText(getBaseContext(), data.getData(),Toast.LENGTH_SHORT).show();
- Toast.makeText(this, "image saved to:n" + data.getData(), Toast.LENGTH_LONG).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement