Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. botonExplorar.setOnClickListener(new View.OnClickListener() {
  2. @Override
  3. public void onClick(View view) {
  4. try {
  5.  
  6. Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
  7. // Filter to only show results that can be "opened", such as a
  8. // file (as opposed to a list of contacts or timezones)
  9. intent.setType("text/plain");
  10.  
  11. intent.addCategory(Intent.CATEGORY_OPENABLE);
  12. // it would be "*/*".
  13. //startActivityForResult(intent, READ_REQUEST_CODE);
  14. startActivityForResult(intent, EDIT_REQUEST_CODE);
  15. } catch (ParseException e) {
  16. e.printStackTrace();
  17. }
  18. }
  19. });
  20.  
  21. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  22. if (resultCode == Activity.RESULT_OK) {
  23. textInfo1.setText("");
  24. textInfo2.setText("");
  25. Uri mediaUri = data.getData();
  26. String mediaPath = mediaUri.getPath();
  27.  
  28. textInfo2.setText(mediaPath);
  29. String selectedImagePath;
  30.  
  31. //MEDIA GALLERY
  32. selectedImagePath = PathUtils.getPath(getApplicationContext(), mediaUri) ;
  33. Log.i("Image File Path", ""+selectedImagePath);
  34. textInfo2.setText(selectedImagePath);
  35. textInfo1.setText(mediaUri.toString());
  36.  
  37. //Toast.makeText(getBaseContext(), data.getData(),Toast.LENGTH_SHORT).show();
  38. Toast.makeText(this, "image saved to:n" + data.getData(), Toast.LENGTH_LONG).show();
  39.  
  40.  
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement