【问题标题】:How to prevent AdobeCreativeSDK automatic save images to android phone?如何防止 Adob​​eCreativeSDK 自动将图像保存到安卓手机?
【发布时间】:2016-11-02 08:16:32
【问题描述】:

每当激活编辑器意图时,我都会遇到问题,sdk 会自动将图像保存到图库中。在意图内完成编辑后再次进行一次。我如何防止这里的自动保存?

AdobeImageEditorActivity.class

protected void performSave(Bitmap bitmap, Uri saveUri, CompressFormat outputFormat, int quality, boolean hires, AdobeImageEditorActivity.FinalAction action) {
        logger.info("performSave, uri:%s, quality: %d, action:%s", new Object[]{saveUri, Integer.valueOf(quality), action});
        File destFile;
        if(saveUri != null) {
            destFile = new File(saveUri.getPath());
        } else {
            destFile = this.getDefaultOutputDestination(outputFormat);
        }

        try {
            logger.log("trying to create the new file...");
            if(!destFile.exists() && !destFile.createNewFile()) {
                logger.error("Failed to create the file");
            }
        } catch (IOException var11) {
            var11.printStackTrace();

            try {
                logger.error("using a temporary file!");
                destFile = File.createTempFile("aviary-image-", ".jpeg");
            } catch (IOException var10) {
                var10.printStackTrace();
            }
        }

        LocalDataService service = (LocalDataService)this.getMainController().getService(LocalDataService.class);

        assert service != null;

        service.setDestImageUri(Uri.parse(destFile.getAbsolutePath()));
        AdobeImageEditorActivity.SaveHiResImageTask mSaveTask = new AdobeImageEditorActivity.SaveHiResImageTask(destFile, action, outputFormat, quality, hires);
        mSaveTask.execute(new Bitmap[]{bitmap});
    }

我意识到上面的代码实际上可能正在执行该保存,但是它是一个自动生成的文件,有什么方法可以防止保存发生吗?

【问题讨论】:

    标签: android-studio uri android-gallery aviary adobecreativesdk


    【解决方案1】:

    使用图像编辑器自动保存

    当用户关闭图像编辑器时,Creative SDK 图像编辑器会保存编辑后的图像。无法阻止这种行为。

    保存的图像UrionActivityResult() 方法中传递回您应用的Activity。有关基本演示,请参阅this sample app on GitHub

    指示编辑后图像的保存位置

    可以使用withOutput() 方法指定编辑后的图像保存在哪里,并传递一个File

    您可以在the Creative SDK developer portal's Image Editor guide 上查看所有可选方法。

    请注意,开发人员门户当前声明您应该将Uri 传递给withOutput(),但这是不正确的。你应该传入一个File

        /* 1) Change the argument to your desired location */
        File file = new File(Environment.getExternalStorageDirectory() + File.separator + "test.jpg");
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    
        Intent imageEditorIntent = new AdobeImageIntent.Builder(this)
                .setData(imageUri)
                .withOutput(file) /* 2) Pass the File here */
                .build();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-03
      • 2018-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-18
      相关资源
      最近更新 更多