I'm trying to share/attach multiple apps apk via intent on button click but the permission denied for attachment in email apps and cannot share via other medium like bluetooth. Is there any other way I can solve this issue? The file isn't just attached or sent. I have given the runtime permissions for storage READ and WRITE both. This is the button clicklistener I've implemented.
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);
}
});
And this method returns the list of URIs.
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;
}