【发布时间】:2012-09-26 22:36:06
【问题描述】:
我希望我的应用程序在启动时检查用户名和密码是否保存在 sharedPreferences 中。如果它检测到这些凭据,则会显示一个登录页面,如果没有,则会显示一个注册页面。用户登录到应用程序后,我希望整个应用程序关闭,无论是按下设备的后退按钮还是按下应用程序退出按钮。
除了应用程序正常关闭之外,我一切正常。我以为我编码正确,但我没有。选择退出和设备后退按钮时,如何关闭整个应用程序。
退出方法:
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
arg0.cancel();
}
});
AlertDialog alert=builder.create();
alert.show();
【问题讨论】:
-
很少有你想在安卓应用中包含退出按钮的情况:blog.radioactiveyak.com/2010/05/…
标签: android android-activity sharedpreferences buttonclick