What is the substitute for WL.App.close?

爷,独闯天下 提交于 2019-12-25 04:23:10

问题


WL.App.close is deprecated. I know that this is not supported for iOS. But why is it deprecated for Android as well? At the moment, it is still functioning fine, even on 6.2, but since it is deprecated, what is the alternative/substitute for this?


回答1:


In Android as well, this is not the recommended approach. You should let the user quit the app, and this is done by manually bringing up the "applications view" and swiping the app in order to quit it.

Can be corroborated by these answers by Googlers:
http://android.nextapp.com/site/fx/doc/exit

Additionally, there are these approaches:

  • Close application and launch home screen on Android
  • https://groups.google.com/forum/#!topic/android-developers/Y96KnN_6RqM

You could write a Cordova plug-in that will force-quit the app and trigger it by overriding whatever you'd like (like the Back button), or create a dedicated Quit button, etc.




回答2:


In MobileFirst 7.0, this method seems to be deprecated in both iOS and Android, but when I call this "deprecated" method in Android, it really works.

I think overriding Android's back button might be a best practice in Android webapp as back button may cause strange page navigating issues (if you use UI frameworks like JQM). This is what I done in WL's main.js.

WL.App.overrideBackButton(backFunc);
function backFunc(){
    WL.SimpleDialog.show(
        "Alert", 
        "Sure to quit the app ?", 
        [ {text : 'Cancel', handler: function() {
        }},
        {text : 'Yes', handler: function() {
            if(WL.Client.getEnvironment() == WL.Environment.ANDROID) {
                WL.App.close();
            }
        }}]
    );
}


来源:https://stackoverflow.com/questions/24793058/what-is-the-substitute-for-wl-app-close

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