-1
任何人都可以幫助解釋爲什麼警告對話框不會顯示這段代碼?它位於主活動的onCreate(Bundle savedInstanceState)方法中。Android AlertDialog在應用程序退出前不顯示
//setup the export directory
if(!Globals.setupExportDir(s_SessionName))
{
AlertDialog.Builder dlgbuilder = new AlertDialog.Builder(this);
dlgbuilder.setTitle("Error message");
dlgbuilder.setMessage("Could not create the directories");
dlgbuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
//just exit
}
});
AlertDialog dlg = dlgbuilder.create();
dlg.show();
System.exit(0);
}
我懷疑這是因爲系統在顯示對話框之前退出,但那麼做什麼纔是正確的方法呢?
在此先感謝您的任何見解。
安德烈
沒有太大的區別,但它值得一試。該應用的表現看起來好像Alertdialog不是模態。我會盡量找到解決辦法。非常感謝。 – WestWind 2014-10-12 11:35:06
使用Toast來代替這個技巧,但爲什麼AlertDialog失敗仍然是一個謎。 – WestWind 2014-10-12 11:44:46