WL.App.overrideBackButton 无效
WL.App.overrideBackButton doesn't work
我正在使用 IBM Mobilefirst Platform 7.1。我正在尝试覆盖 Android 中后退按钮的标准行为。我创建了新的 Mobilefirst 项目 "Hello Mobilefirst"。在 main.js 中,我覆盖了后退按钮功能。我 运行 三星 Note 4 上的应用程序和后退按钮仅关闭应用程序而不显示消息。如果我使用 alert 而不是 WL.SimpleDialog.show 应用程序显示消息,但之后它关闭应用程序。如何仅在按 YES 时关闭应用程序?
index.html
<body style="display: none;">
Hello MobileFirst
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
</body>
main.js
function wlCommonInit(){
}
WL.App.overrideBackButton(checkQuit());
function checkQuit() {
WL.SimpleDialog.show(
"Quit application",
"Are you sure?",
[
{text: "Yes", handler: function() {WL.App.close();}},
{text: "No", handler: function() {}}
]
);
}
谢谢!
WL.App.close() API 将不再实际退出应用程序,因为这不是推荐的行为。不是 Apple 也不是 Google。如果您想 force-quit 该应用程序,您将需要触发执行此操作的本机代码。
看这里:What is the substitute for WL.App.close?
首先需要找到客户端环境,在main.js文件中写入如下代码
if(WL.Client.getEnvironment().toUpperCase() == "ANDROID"){
WL.App.overrideBackButton(backFunc);
}
function backFunc() {
// alert('You will back to previous page');
}
我正在使用 IBM Mobilefirst Platform 7.1。我正在尝试覆盖 Android 中后退按钮的标准行为。我创建了新的 Mobilefirst 项目 "Hello Mobilefirst"。在 main.js 中,我覆盖了后退按钮功能。我 运行 三星 Note 4 上的应用程序和后退按钮仅关闭应用程序而不显示消息。如果我使用 alert 而不是 WL.SimpleDialog.show 应用程序显示消息,但之后它关闭应用程序。如何仅在按 YES 时关闭应用程序?
index.html
<body style="display: none;">
Hello MobileFirst
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
</body>
main.js
function wlCommonInit(){
}
WL.App.overrideBackButton(checkQuit());
function checkQuit() {
WL.SimpleDialog.show(
"Quit application",
"Are you sure?",
[
{text: "Yes", handler: function() {WL.App.close();}},
{text: "No", handler: function() {}}
]
);
}
谢谢!
WL.App.close() API 将不再实际退出应用程序,因为这不是推荐的行为。不是 Apple 也不是 Google。如果您想 force-quit 该应用程序,您将需要触发执行此操作的本机代码。
看这里:What is the substitute for WL.App.close?
首先需要找到客户端环境,在main.js文件中写入如下代码
if(WL.Client.getEnvironment().toUpperCase() == "ANDROID"){
WL.App.overrideBackButton(backFunc);
}
function backFunc() {
// alert('You will back to previous page');
}