附件的权限被拒绝-无法通过意图附加或共享文件

时间:2018-08-09 12:39:36

标签: android android-intent android-permissions

我试图通过意图单击按钮来共享/附加多个apk,但电子邮件应用中的附件权限被拒绝,并且无法通过其他媒介(如蓝牙)进行共享。我还有其他方法可以解决此问题吗? 该文件不只是附加或发送的。我已授予运行时存储READ和WRITE的权限。这是我实现的按钮clicklistener。

   share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            intent.setType("*/*");
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, getUriArray());
            intent.setType("text/plain");
            startActivityForResult(intent, 5);
        }
    });

然后此方法返回URI列表。

 public ArrayList<Uri> getUriArray(){
        String filePath="";
        ArrayList<Uri> arrayURI=new ArrayList<Uri>();
        for (int i = 0; i < appList.size(); i++) {
            AllApps singleApp = appList.get(i);
            if (singleApp.isSelected() == true) {
                String app_pkg_name = singleApp.getPackageName();
                try{
                    ApplicationInfo app = getPackageManager().getApplicationInfo(app_pkg_name, 0);
                    filePath = app.sourceDir;

                }catch (PackageManager.NameNotFoundException e){
                    e.printStackTrace();
                }
                arrayURI.add(Uri.fromFile(new File(filePath)));
            }
        }
        return arrayURI;
    }

0 个答案:

没有答案