Search in sources :

Example 6 with FileProvider

use of android.support.v4.content.FileProvider in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    switch(requestCode) {
        case BUG_REPORT_STORAGE_PERMISSION_REQUEST_CODE:
            if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
                File zipFile = new File(getActivity().getCacheDir() + File.separator + "export", "report.zip");
                // Move files and send email
                final Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.dev_email) });
                intent.putExtra(Intent.EXTRA_SUBJECT, "MaxLock feedback on " + Build.MODEL);
                intent.putExtra(Intent.EXTRA_TEXT, "Please here describe your issue as DETAILED as possible!");
                Uri uri = getUriForFile(getContext(), "de.Maxr1998.fileprovider", zipFile);
                intent.putExtra(Intent.EXTRA_STREAM, uri);
                new AlertDialog.Builder(getActivity()).setMessage(R.string.dialog_message_bugreport_finished_select_email).setPositiveButton(android.R.string.ok, (dialog, which) -> startActivity(Intent.createChooser(intent, getString(R.string.share_menu_title_send_email)))).create().show();
            }
            break;
    }
}
Also used : CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) Uri(android.net.Uri)

Aggregations

Intent (android.content.Intent)6 Uri (android.net.Uri)6 FileProvider.getUriForFile (android.support.v4.content.FileProvider.getUriForFile)4 File (java.io.File)4 DownloadManager (android.app.DownloadManager)1 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 ClipboardManager (android.content.ClipboardManager)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)1 FileProvider (android.support.v4.content.FileProvider)1 DocumentFile (android.support.v4.provider.DocumentFile)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1