|
3 | 3 | import android.Manifest;
|
4 | 4 | import android.app.AlertDialog;
|
5 | 5 | import android.content.ActivityNotFoundException;
|
| 6 | +import android.content.ComponentName; |
6 | 7 | import android.content.Context;
|
| 8 | +import android.content.DialogInterface; |
7 | 9 | import android.content.Intent;
|
8 | 10 | import android.content.SharedPreferences;
|
9 | 11 | import android.content.pm.PackageManager;
|
| 12 | +import android.content.pm.ResolveInfo; |
10 | 13 | import android.net.Uri;
|
11 | 14 | import android.os.Build;
|
12 | 15 | import android.os.Bundle;
|
|
21 | 24 | import android.widget.Toast;
|
22 | 25 |
|
23 | 26 | import java.io.File;
|
| 27 | +import java.util.ArrayList; |
| 28 | +import java.util.List; |
24 | 29 |
|
25 | 30 | import javax.inject.Inject;
|
26 | 31 | import javax.inject.Named;
|
@@ -141,19 +146,24 @@ private void sendAppLogsViaEmail() {
|
141 | 146 | appLogsFile
|
142 | 147 | );
|
143 | 148 |
|
144 |
| - Intent feedbackIntent = new Intent(Intent.ACTION_SEND); |
145 |
| - feedbackIntent.setType("message/rfc822"); |
146 |
| - feedbackIntent.putExtra(Intent.EXTRA_EMAIL, |
147 |
| - new String[]{CommonsApplication.LOGS_PRIVATE_EMAIL}); |
148 |
| - feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, |
149 |
| - String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, |
150 |
| - BuildConfig.VERSION_NAME)); |
151 |
| - feedbackIntent.putExtra(Intent.EXTRA_STREAM,appLogsFilePath); |
| 149 | + //initialize the emailSelectorIntent |
| 150 | + Intent emailSelectorIntent = new Intent(Intent.ACTION_SENDTO); |
| 151 | + emailSelectorIntent.setData(Uri.parse("mailto:")); |
| 152 | + //initialize the emailIntent |
| 153 | + final Intent emailIntent = new Intent(Intent.ACTION_SEND); |
| 154 | + emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{CommonsApplication.FEEDBACK_EMAIL}); |
| 155 | + emailIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME)); |
| 156 | + emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 157 | + emailIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| 158 | + emailIntent.setSelector( emailSelectorIntent ); |
| 159 | + //adding the attachment to the intent |
| 160 | + emailIntent.putExtra(Intent.EXTRA_STREAM, appLogsFilePath); |
152 | 161 |
|
153 | 162 | try {
|
154 |
| - startActivity(feedbackIntent); |
| 163 | + startActivity(Intent.createChooser(emailIntent, "Send mail..")); |
155 | 164 | } catch (ActivityNotFoundException e) {
|
156 | 165 | Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
157 | 166 | }
|
158 | 167 | }
|
| 168 | + |
159 | 169 | }
|
0 commit comments