问题
We have created a phonegap application for android with phonegap version-1.3.
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()
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