在我的申请中,我发送邮件。要发送邮件,我已将Gmail设为默认值。但是点击后退导航,我想导航回我的应用程序,但正在显示Gmail的收件箱。 以下是我的代码:
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{
"abc.k@india.dharma.com" });
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 1);
ResolveInfo best = null;
for (final ResolveInfo info : matches)
if (info.activityInfo.packageName.endsWith(".gm")
|| info.activityInfo.name.toLowerCase()
.contains("gmail"))
best = info;
if (best != null)
intent.setClassName(best.activityInfo.packageName,
best.activityInfo.name);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// Copy file to external storage
InputStream in = null;
OutputStream out = null;
AssetManager assetManager = getAssets();
LifeUser lt = new LifeUser(getApplicationContext());
LifeTimestamp lts = new LifeTimestamp();
String desFile = "genReport"
+ lts.get(Calendar.DAY_OF_MONTH) + ".txt";
try {
lt.generateReportLog(desFile);
} catch (Exception e) {
Log.e("", e.getMessage());
}
// Get the Uri from the external file and add it to the
// intent
Uri uri = Uri.fromFile(new File(Environment
.getExternalStorageDirectory(), desFile));
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
答案 0 :(得分:0)
从gmail单击后退按钮时,您的代码无关紧要。无论gmail定义为后退按钮的行为都将被执行。离开gmail后,将调用堆栈中的下一个较低的Activity,这可能是您的Activity。