Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 11-28 13:39:09.266: I/System.out(7950): filemangerstring = /external/images/media/2431
- 11-28 13:39:09.266: I/System.out(7950): selectedImagePath = /storage/sdcard0/Pictures/Screenshots/Screenshot_2014-11-28-13-27-26.png
- 11-28 13:39:09.266: I/System.out(7950): filePathImage1 = /storage/sdcard0/Pictures/Screenshots/Screenshot_2014-11-28-13-27-26.png
- 11-28 13:41:07.776: I/System.out(7950): filemangerstring = /0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d
- 11-28 13:41:07.776: I/System.out(7950): selectedImagePath = null
- 11-28 13:41:07.776: I/System.out(7950): filePathImage1 = /0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d
- 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)
- 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)
- 11-28 13:41:07.776: E/JHEAD(7950): can't open '/0/https://lh6.googleusercontent.com/ATCu2g0Tg_myGn8oBFbjtS_D4cYNTqUUnU2jBTDiz10=s0-d'
- String filemanagerstring = selectedImageUri.getPath();
- String selectedImagePath = getPath(selectedImageUri);
- public String getPath(Uri uri) {
- try {
- String[] proj = { MediaStore.Images.Media.DATA };
- Cursor cursor = managedQuery(uri, proj, null, null, null);
- int column_index = cursor
- .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- cursor.moveToFirst();
- return cursor.getString(column_index);
- } catch (Exception e) {
- return uri.getPath();
- }
- }
- case R.id.cameraWallBtn:
- cameraBtn.setEnabled(false);
- Intent intent = new Intent(Intent.ACTION_PICK);
- intent.setType("image/*");
- Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- Random generator = new Random();
- int n = 10000;
- n = generator.nextInt(n);
- fileName = n + ".jpg";
- String u = Environment.getExternalStorageDirectory().getPath()
- + "/" + fileName;
- imageUri = Uri.fromFile(new File(u));
- i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
- Intent chooserIntent = Intent.createChooser(intent,
- "Select Picture...");
- chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
- new Intent[] { i });
- startActivityForResult(chooserIntent, FIRST_IMAGE);
- cameraBtn.setEnabled(true);
- break;
- private String filePathImage1 = null;
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case FIRST_IMAGE:
- if (resultCode == Activity.RESULT_OK) {
- Uri selectedImageUri;
- if (data != null) {
- if (data.getData() != null)
- selectedImageUri = data.getData();
- else
- selectedImageUri = imageUri;
- } else
- selectedImageUri = imageUri;
- try {
- String filemanagerstring = selectedImageUri.getPath();
- String selectedImagePath = getPath(selectedImageUri);
- System.out.println("filemangerstring = "+filemanagerstring);
- System.out.println("selectedImagePath = "+selectedImagePath);
- if (selectedImagePath != null) {
- filePathImage1 = selectedImagePath;
- } else if (filemanagerstring != null) {
- filePathImage1 = filemanagerstring;
- } else {
- Log.e("Bitmap", "Unknown path");
- }
- System.out.println("filePathImage1 = "+filePathImage1);
- if (filePathImage1 != null) {
- displayInImageViewAndRotateIfNeed(filePathImage1,
- imagePreview);
- } else {
- imagePreview.setVisibility(View.GONE);
- }
- } catch (Exception e) {
- Toast.makeText(getApplicationContext(),
- "Internal error" + e.toString(), Toast.LENGTH_LONG)
- .show();
- Log.e(e.getClass().getName(), e.getMessage(), e);
- }
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement