简体   繁体   English

未找到处理 Intent{typ=andrid.intent.action.PICK} 的活动

[英]No Activity found to handle Intent{typ=andrid.intent.action.PICK}

Well, I can't recognize why the problem below show up.好吧,我不明白为什么会出现下面的问题。 I created an imageView button that when it is clicked it should open gallery to choose an image.我创建了一个imageView按钮,单击它时应该打开图库以选择图像。 Although, it triggers the following problem: No Activity found to handle Intent{typ=andrid.intent.action.PICK} .虽然,它触发了以下问题: No Activity found to handle Intent{typ=andrid.intent.action.PICK} Take a look at the code I wrote.看看我写的代码。

private ImageView imgContainer
private Bitmap storedImg;
private static final int PICK_IMAGE_REQUEST = 100;
private Uri imgPath;
postTypes = view.findViewById(R.id.PostOptions);

try {
       imgContainer = view.findViewById(R.id.pressToUpload);
    } catch (Exception e) {

    }

imgContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    Intent intent = new Intent();
                    intent.setType("image/*");

                    intent.setType(Intent.ACTION_PICK);
                    startActivityForResult(intent, PICK_IMAGE_REQUEST);
                } catch (Exception e) {
                    Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }
        });

postTypes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupMenu menu = new PopupMenu(getContext(), postTypes);
                menu.getMenuInflater()
                        .inflate(R.menu.post_options, menu.getMenu());

                menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        
                        switch (item.getItemId()) {
                            case R.id.txtOption:
                                imgPreview.setVisibility(View.GONE);
                                return true;
                            case R.id.imgOption:
                                imgPreview.setVisibility(View.VISIBLE);
                                return true;
                            case R.id.vdOption:
                                imgPreview.setVisibility(View.GONE);
                                break;

                        }
                        return true;
                    }
                });
                menu.show();
            }
        });

@Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
        try {
            ContentResolver resolver = getActivity().getContentResolver();
            super.onActivityResult(requestCode, resultCode, data);
            if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data!=null && data.getData()!=null) {
                imgPath = data.getData();
                storedImg = MediaStore.Images.Media.getBitmap(resolver, imgPath);

                imgContainer.setImageBitmap(storedImg);
            }
        } catch (Exception e) {

        }

    }

Is it a problem with ACTION_PICK ? ACTION_PICK有问题吗? Before ACTION_PICK I tried ACTION_GET_CONTENT but the same issue was triggered.ACTION_PICK之前,我尝试ACTION_GET_CONTENT但触发了相同的问题。 What does it need in order to open the gallery?打开画廊需要什么?

Could you try this, ACTION_PICK fails sometimes when the phone doesn't properly support it.你能试试这个吗, ACTION_PICK有时会在手机不能正确支持它时失败。

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_VIEW);  
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

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

相关问题 找不到用于处理意图的活动{act = android.intent.action.OPEN_DOCUMENT cat = [android.intent.category.OPENABLE] typ = / *} - No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] typ=/* } 找不到活动来处理意图与操作和数据 - No Activity found to handle Intent with action and data 找不到用于处理意图的活动{act = android.intent.action.View} - No activity found to handle intent { act=android.intent.action.View } 没有找到处理意图的活动{act=android,intent.action.VIEW} - No activity found to handle intent{act=android,intent.action.VIEW} 找不到可通过ACTION_VIEW Intent处理Intent的活动 - No Activity found to handle Intent With ACTION_VIEW Intent 找不到活动来处理意图错误 - No Activity found to handle intent errors “找不到活动来处理意图”错误 - “No activity found to handle intent” error 找不到可处理意图的活动,Android - no activity found to handle intent, android 找不到用于处理Intent {的活动“ act = android.intent.action.CALL dat =电话号码:1}? - No Activity found to handle Intent{ act=android.intent.action.CALL dat=Phone number:1 }? 找不到处理 Intent { act=android.intent.action.CALL dat=tel0710000001 } 的活动 - No Activity found to handle Intent { act=android.intent.action.CALL dat=tel0710000001 }
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM