简体   繁体   English

Android bug:裁剪意图适用于某些设备

[英]Android bug: Crop intent works on some devices

Android bug: Crop intent works on some file managers. Android bug:裁剪意图适用于某些文件管理器。

Following code: 以下代码:

Launch intent to crop image from folder/file. 启动意图从文件夹/文件中裁剪图像。

Intent intent = new Intent(Intent.ACTION_GET_CONTENT,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

        //intent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString());
        intent.putExtra("crop", "true");
        intent.putExtra("return-data", true);

        startActivityForResult(intent, 0);

2 versions of code crash differently on different devices, same Android version. 2个版本的代码在不同的设备上崩溃,相同的Android版本。

1st verison: 第一个版本:

try 
    {
        bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), targetUri);

        }catch (FileNotFoundException e){e.printStackTrace();} 
        catch (IOException e){e.printStackTrace();}

Second version (works on other devices) 第二版(适用于其他设备)

bitmap = (Bitmap) data.getExtras().get("data");

What am I suppose to do? 我该怎么办?

The com.android.camera.action.CROP is part of the internal API so it is not guaranteed to be supported by all Android devices. com.android.camera.action.CROP是内部API的一部分,因此不保证所有Android设备都支持它。

You will have to implement your own crop activity if you want it to be supported by all devices. 如果您希望所有设备都支持,您必须实施自己的裁剪活动。 At the very least you should implement some sort of fallback behavior if some device does not support the Intent . 如果某些设备不支持Intent至少应该实现某种回退行为。 PLEASE DON'T FORGET TO DO THIS!! 请不要忘记这样做!! :) :)

And by the way, if I recall correctly, the Samsung Galaxy implements its own Media/Gallery app, so that is why it is failing to recognize the Intent. 顺便说一句,如果我没记错的话,三星Galaxy实现了自己的媒体/图库应用程序,这就是它无法识别意图的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM