Guest User

Untitled

a guest
Jan 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. protected void onActivityResult(int requestCode, int resultCode,Intent data) {
  2. if (resultCode == RESULT_OK) {
  3. Uri targetUri = data.getData();
  4. Bitmap bitmap = null;
  5. bitmap = BitmapFactory.decodeFile(getRealPathFromURI(targetUri));
  6. //bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
  7. addMarker(bitmap);
  8. }
  9. }
  10.  
  11. public String getRealPathFromURI(Uri contentUri) {
  12. // can post image
  13. String [] proj={MediaStore.Images.Media.DATA};
  14. Cursor cursor = managedQuery( contentUri,
  15. proj, // Which columns to return
  16. null, // WHERE clause; which rows to return (all rows)
  17. null, // WHERE clause selection arguments (none)
  18. null); // Order-by clause (ascending by name)
  19. int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  20. cursor.moveToFirst();
  21. return cursor.getString(column_index);
  22. }
  23.  
  24. 09-29 21:28:35.960: E/AndroidRuntime(4746):
  25. java.lang.RuntimeException: Failure delivering result ResultInfo
  26. {who=null, request=1, result=-1, data=Intent
  27. { dat=content://media/external/images/media/3 }} to activity
  28. {com.sit.augmented_reality/com.sit.augmented_reality.activity.Demo}:
  29. java.lang.NullPointerException
Add Comment
Please, Sign In to add comment