@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (backTip)
{
backTip = false;
Toast.makeText(this,"再按一次返回鍵回到主屏幕", Toast.LENGTH_SHORT).show();
new Thread()
{
public void run()
{
try
{
Thread.sleep(3000);
backTip = true;
} catch (InterruptedException e)
{
e.printStackTrace();
}
};
}.start();
}
else
{
Intent backHome = new Intent(Intent.ACTION_MAIN);
backHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
backHome.addCategory(Intent.CATEGORY_HOME);
startActivity(backHome);
System.exit(0);
}
return true;
}
return super.onKeyDown(keyCode, event); }