splash screen appears on click of android device BACK button — Created using PhoneGap

假如想象 提交于 2019-12-24 09:17:14

问题


We have created a phonegap application for android with phonegap version-1.3.

  1. When I am on any page of the application, and start using the device BACK button, the Android SPLASH screen appears/pops sometimes, and then the previously accessed page is shown.

    function onBackKeyPress()

  2. Sometimes when i click on some links which open the browser, and after i click on back button, its Showing Splash screen and relaunch the application.

Is there any other function we can use for back button?


回答1:


From the activity before splash screen from which you wish to exit application override onBackpress.

@Override
public void onBackPressed() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

}


来源:https://stackoverflow.com/questions/9393357/splash-screen-appears-on-click-of-android-device-back-button-created-using-ph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!