final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND_MULTIPLE);
// Recording file send to mail
//emailIntent.setType("image/png");
//emailIntent.setType("audio/3gp");
emailIntent.putExtra("data", sourceImageBitmap);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//emailIntent.setType("application/email");
emailIntent.setType("vnd.android.cursor.dir/email");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"user@example.com"});
emailIntent.putExtra(
android.content.Intent.EXTRA_EMAIL,
new String[] { getSharedPreferences(
"emailedittext", 0).getString(
"emailedittext_value", "") });
emailIntent.putExtra(
android.content.Intent.EXTRA_SUBJECT,
"Complaint");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Attached in the mail is the complaint for coordinate"
+ "\n" + "latitude "
+ issueLatitudeString + "\n"
+ "longitude " + issueLongitudeString
+ "\n" + "for place "
+ issueAddressString );
String s = emailIntent.getPackage();
emailIntent.putParcelableArrayListExtra(
Intent.EXTRA_STREAM, uris);
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm
.queryIntentActivities(emailIntent, 0);
final ResolveInfo[] best = new ResolveInfo[matches
.size()];
ArrayList<String> emailList = new ArrayList<String>();
String space = " ";
itemActivity = 0;
for (final ResolveInfo info : matches) {
if ( info.activityInfo.applicationInfo.className
.toLowerCase().contains("mail")) {
best[itemActivity] = info;
String res = info.activityInfo.applicationInfo.className;
emailList.add(space
+ res.substring(res.lastIndexOf(".") + 1));
itemActivity++;
}
}
int i = 0;
String item[] = new String[emailList.size()];
for (String string : emailList) {
item[i++] = string;
}
if (item[0]!=null) {
AlertDialog.Builder builder = new AlertDialog.Builder(
NewIssue.this);
builder.setTitle("Pick an item");
builder.setIcon(best[0].activityInfo.getIconResource());
builder.setItems(item,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog, int item) {
emailIntent
.setClassName(
best[item].activityInfo.packageName,
best[item].activityInfo.name);
startActivity(emailIntent);
finish();
}
});
//builder.setIcon(best[itemActivity-1].activityInfo.icon);
AlertDialog alert = builder.create();
alert.show();
} else {
startActivity(emailIntent);
}
android.content.Intent.ACTION_SEND_MULTIPLE);
// Recording file send to mail
//emailIntent.setType("image/png");
//emailIntent.setType("audio/3gp");
emailIntent.putExtra("data", sourceImageBitmap);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//emailIntent.setType("application/email");
emailIntent.setType("vnd.android.cursor.dir/email");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"user@example.com"});
emailIntent.putExtra(
android.content.Intent.EXTRA_EMAIL,
new String[] { getSharedPreferences(
"emailedittext", 0).getString(
"emailedittext_value", "") });
emailIntent.putExtra(
android.content.Intent.EXTRA_SUBJECT,
"Complaint");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Attached in the mail is the complaint for coordinate"
+ "\n" + "latitude "
+ issueLatitudeString + "\n"
+ "longitude " + issueLongitudeString
+ "\n" + "for place "
+ issueAddressString );
String s = emailIntent.getPackage();
emailIntent.putParcelableArrayListExtra(
Intent.EXTRA_STREAM, uris);
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm
.queryIntentActivities(emailIntent, 0);
final ResolveInfo[] best = new ResolveInfo[matches
.size()];
ArrayList<String> emailList = new ArrayList<String>();
String space = " ";
itemActivity = 0;
for (final ResolveInfo info : matches) {
if ( info.activityInfo.applicationInfo.className
.toLowerCase().contains("mail")) {
best[itemActivity] = info;
String res = info.activityInfo.applicationInfo.className;
emailList.add(space
+ res.substring(res.lastIndexOf(".") + 1));
itemActivity++;
}
}
int i = 0;
String item[] = new String[emailList.size()];
for (String string : emailList) {
item[i++] = string;
}
if (item[0]!=null) {
AlertDialog.Builder builder = new AlertDialog.Builder(
NewIssue.this);
builder.setTitle("Pick an item");
builder.setIcon(best[0].activityInfo.getIconResource());
builder.setItems(item,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog, int item) {
emailIntent
.setClassName(
best[item].activityInfo.packageName,
best[item].activityInfo.name);
startActivity(emailIntent);
finish();
}
});
//builder.setIcon(best[itemActivity-1].activityInfo.icon);
AlertDialog alert = builder.create();
alert.show();
} else {
startActivity(emailIntent);
}
No comments:
Post a Comment