【问题标题】:Missing confirm button on multiselect image picker多选图像选择器上缺少确认按钮
【发布时间】:2019-12-02 07:52:31
【问题描述】:

screenshot 我正在以 ACTION_GET_CONTENT 意图打开画廊活动。我可以选择多个图像,但我错过了结果活动的返回按钮。我该如何实现呢?

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    String[] mimeTypes = {"image/jpeg", "image/png"};
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    setResult(Activity.RESULT_OK, intent);
    startActivityForResult(intent, PICK_IMAGE);

【问题讨论】:

  • 尝试在您的手机中使用不同的图像选择器应用程序,这可能是图库/图像选择器应用程序的问题。

标签: android android-intent gallery


【解决方案1】:

只用谷歌照片打开图片:

   Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getIntent.setType("image/*");
    getIntent.addCategory(Intent.CATEGORY_OPENABLE);


    getIntent.setType("image/*");
    String[] mimeTypes = {"image/jpeg", "image/png"};
    getIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);

    Intent chooserIntent = null;

    if(isGooglePhotosInstalled(getApplicationContext())) {

        List<ResolveInfo> mApps = getApplicationContext().getPackageManager().queryIntentActivities(getIntent, 0);
        ResolveInfo info = mApps.get(3);
        String packageName = info.activityInfo.packageName;
        getIntent.setPackage(packageName);
        getIntent.putExtra("crop", "true");
        getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        startActivityForResult(getIntent, PICK_IMAGE);

    } else {

        //Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);

        chooserIntent = Intent.createChooser(getIntent, "Select Image");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});

        pickIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        //getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

        startActivityForResult(chooserIntent, PICK_IMAGE);

    }

【讨论】:

    猜你喜欢
    • 2014-06-16
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 2013-12-24
    • 2014-06-28
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    相关资源
    最近更新 更多