Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用意图时从微调器中选择数据,并从存储设备中选择pdf_Java_Android_Android Intent - Fatal编程技术网

Java 使用意图时从微调器中选择数据,并从存储设备中选择pdf

Java 使用意图时从微调器中选择数据,并从存储设备中选择pdf,java,android,android-intent,Java,Android,Android Intent,您好,希望您做得很好。当我使用intent时,在微调器上设置数据时,我遇到了一个问题 从存储器中获取文件,并在微调器中选择所选数据 private void getPDF() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERN

您好,希望您做得很好。当我使用intent时,在微调器上设置数据时,我遇到了一个问题 从存储器中获取文件,并在微调器中选择所选数据

private void getPDF() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                    Uri.parse("package:" + getPackageName()));
            startActivity(intent);
            return;
        }

        //creating an intent for file chooser
        Intent intent = new Intent();
        intent.setType("application/pdf");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Document"), PICK_PDF_CODE);
    }