Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. fabLayoutGallery.setOnClickListener(v -> {
  2. Intent fileintent = new Intent(Intent.ACTION_GET_CONTENT);
  3. fileintent.setType("image/*");
  4. try {
  5. startActivityForResult(Intent.createChooser(fileintent, "Select Picture"), REAUEST_CODE_IMAGE_GALLERY);
  6.  
  7. } catch (ActivityNotFoundException e) {
  8. Log.e("tag", "No activity can handle picking a file. Showing alternatives.");
  9. }
  10. });
  11.  
  12. @Override
  13. protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  14. super.onActivityResult(requestCode, resultCode, data);
  15. if (requestCode == REAUEST_CODE_IMAGE_GALLERY && resultCode == RESULT_OK) {
  16. Uri imageUri = data.getData();
  17. String path = data.getDataString();
  18.  
  19. Bitmap bmp = null;
  20. try {
  21. bmp = getThumbnail(this, imageUri);
  22. formDataRequest(path);
  23. } catch (IOException e) {
  24. e.printStackTrace();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement