List of usage examples for android.app Activity grantUriPermission
@Override public void grantUriPermission(String toPackage, Uri uri, int modeFlags)
From source file:org.wahtod.wififixer.utility.LogUtil.java
public static void sendIssueReport(Activity activity, String report, File file) { Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(activity.getString(R.string.log_mimetype)); sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.email) }); sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.subject)); Uri uri = FileProvider.getUriForFile(activity, "org.wahtod.wififixer.files", file); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); }//from w ww. j av a 2 s .c o m sendIntent.putExtra(Intent.EXTRA_TEXT, LogUtil.getBuildInfo() + "\n\n" + report); activity.startActivityForResult(Intent.createChooser(sendIntent, activity.getString(R.string.emailintent)), 1); }