在我的android應用程序有一個按鈕發送郵件,當我點擊發送按鈕使用這行Gmail將打開,然後我點擊發送郵件。爲什麼郵件會在我的應用程序關閉的同時成功發送?我需要留在同一頁面?當我調用intent.createChooser發送郵件時自動關閉應用程序?
try
{
String extpath=Environment.getExternalStorageDirectory() +"/NewFolder/DBName";
File pathp=new File(extpath);
Log.d("New Path", pathp.toString());
long fileSize = pathp.length();
if(fileSize > 0)
{
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String address = "[email protected]";
String subject = "Database";
String emailtext = "Please check the attached database and save it";
emailIntent.setType("application/octet-stream");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { address });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + pathp));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext);
startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
}
else
{
Log.d("Error", "Attachment didn't attach ");
}
}
catch (Throwable t)
{
Log.d("Error on sending mail", t.toString());
}
當我運行此代碼郵件發送,然後應用程序將關閉。我不想關閉應用程序。提前幫助我感謝。
發佈了一些相關的代碼 – kgandroid 2014-09-19 12:15:47
@kgandroid我更新了我的問題,好心的讀了它 – Sri 2014-09-19 12:23:53
@Sri你有什麼錯誤? – 2014-09-19 12:34:51