Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. 11-28 13:39:09.266: I/System.out(7950): filemangerstring = /external/images/media/2431
  2. 11-28 13:39:09.266: I/System.out(7950): selectedImagePath = /storage/sdcard0/Pictures/Screenshots/Screenshot_2014-11-28-13-27-26.png
  3. 11-28 13:39:09.266: I/System.out(7950): filePathImage1 = /storage/sdcard0/Pictures/Screenshots/Screenshot_2014-11-28-13-27-26.png
  4.  
  5. 11-28 13:41:07.776: I/System.out(7950): filemangerstring = /0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d
  6. 11-28 13:41:07.776: I/System.out(7950): selectedImagePath = null
  7. 11-28 13:41:07.776: I/System.out(7950): filePathImage1 = /0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d
  8. 11-28 13:41:07.776: E/BitmapFactory(7950): Unable to decode stream: java.io.FileNotFoundException: /0/https:/lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d: open failed: ENOENT (No such file or directory)
  9. 11-28 13:41:07.776: E/BitmapFactory(7950): Unable to decode stream: java.io.FileNotFoundException: /0/https:/lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d: open failed: ENOENT (No such file or directory)
  10. 11-28 13:41:07.776: E/JHEAD(7950): can't open '/0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d'
  11.  
  12. String filemanagerstring = selectedImageUri.getPath();
  13. String selectedImagePath = getPath(selectedImageUri);
  14.  
  15. public String getPath(Uri uri) {
  16. try {
  17. String[] proj = { MediaStore.Images.Media.DATA };
  18. Cursor cursor = managedQuery(uri, proj, null, null, null);
  19. int column_index = cursor
  20. .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  21. cursor.moveToFirst();
  22. return cursor.getString(column_index);
  23. } catch (Exception e) {
  24. return uri.getPath();
  25. }
  26. }
  27.  
  28. case R.id.cameraWallBtn:
  29.  
  30. cameraBtn.setEnabled(false);
  31.  
  32. Intent intent = new Intent(Intent.ACTION_PICK);
  33. intent.setType("image/*");
  34.  
  35. Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  36.  
  37. Random generator = new Random();
  38. int n = 10000;
  39. n = generator.nextInt(n);
  40.  
  41. fileName = n + ".jpg";
  42.  
  43. String u = Environment.getExternalStorageDirectory().getPath()
  44. + "/" + fileName;
  45. imageUri = Uri.fromFile(new File(u));
  46. i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
  47.  
  48. Intent chooserIntent = Intent.createChooser(intent,
  49. "Select Picture...");
  50. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
  51. new Intent[] { i });
  52.  
  53. startActivityForResult(chooserIntent, FIRST_IMAGE);
  54.  
  55. cameraBtn.setEnabled(true);
  56.  
  57. break;
  58.  
  59. private String filePathImage1 = null;
  60.  
  61. @Override
  62. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  63.  
  64. switch (requestCode) {
  65.  
  66. case FIRST_IMAGE:
  67. if (resultCode == Activity.RESULT_OK) {
  68.  
  69. Uri selectedImageUri;
  70. if (data != null) {
  71. if (data.getData() != null)
  72. selectedImageUri = data.getData();
  73. else
  74. selectedImageUri = imageUri;
  75. } else
  76. selectedImageUri = imageUri;
  77.  
  78. try {
  79. String filemanagerstring = selectedImageUri.getPath();
  80. String selectedImagePath = getPath(selectedImageUri);
  81.  
  82. System.out.println("filemangerstring = "+filemanagerstring);
  83. System.out.println("selectedImagePath = "+selectedImagePath);
  84.  
  85. if (selectedImagePath != null) {
  86. filePathImage1 = selectedImagePath;
  87. } else if (filemanagerstring != null) {
  88. filePathImage1 = filemanagerstring;
  89. } else {
  90. Log.e("Bitmap", "Unknown path");
  91. }
  92.  
  93. System.out.println("filePathImage1 = "+filePathImage1);
  94.  
  95. if (filePathImage1 != null) {
  96.  
  97. displayInImageViewAndRotateIfNeed(filePathImage1,
  98. imagePreview);
  99.  
  100. } else {
  101. imagePreview.setVisibility(View.GONE);
  102. }
  103.  
  104. } catch (Exception e) {
  105. Toast.makeText(getApplicationContext(),
  106. "Internal error" + e.toString(), Toast.LENGTH_LONG)
  107. .show();
  108. Log.e(e.getClass().getName(), e.getMessage(), e);
  109. }
  110.  
  111. }
  112.  
  113. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement