Я хочу вернуться к исходной активности после отправки электронной почты, запустив почтовый клиент в Android.Но это не работает вообще.Я пробовал следующий код.
try {
path = android.provider.MediaStore.Images.Media.insertImage(
getContentResolver(), returnedBitmap, "diploma.png", null);
Uri diplomaUri = Uri.parse(path);
//send email with the above generated image as attachment
final Intent emailIntent2 =
new Intent(android.content.Intent.ACTION_SEND);
emailIntent2.putExtra(Intent.EXTRA_SUBJECT,
"Potty Diploma for Teddy");
emailIntent2.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(""));
emailIntent2.putExtra(Intent.EXTRA_STREAM, diplomaUri);
emailIntent2.setType("image/png");
startActivityForResult(Intent.createChooser(emailIntent2, "Email:"),
EMAIL_SUCCESS);
} catch(Exception e) {
final AlertDialog.Builder builder =
new AlertDialog.Builder(v.getContext());
builder.setTitle("Device Media Access");
builder.setMessage("Failed to access media store of the device");
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data){
super.onActivityResult(reqCode, resultCode, data);
switch(reqCode){
case (EMAIL_SUCCESS):
if (resultCode == RESULT_OK){
Intent myIntent = new Intent(Progress.this, iGoPotty.class);
myIntent.putExtra("tab_id", 2);
startActivity(myIntent);
}
}
}