0

我有一个应用程序,它请求图像:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, REQUEST_CODE);

然后用户从对话框中选择一个应用程序,其中包含“始终”和“仅一次”选项。问题是“总是”不起作用。当startActivityForResult(intent, REQUEST_CODE);第二次调用时,对话框再次出现。我该如何处理?

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK){
            try {
                InputStream stream = getContentResolver().openInputStream(
                        data.getData());
                originalBitmap = BitmapFactory.decodeStream(stream);
                stream.close();

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

0 回答 0