MobileFirst 7.1 + Ionic - App.overrideBackButton崩溃

时间:2016-03-26 11:58:52

标签: android ionic-framework ibm-mobilefirst

在点击安卓后退按钮时,Ionic崩溃的MobileFirst应用程序(我用App.overrideBackButton()覆盖)。

我写了一个非常简单的测试应用程序(新项目,新工作区),首先没有Ionic然后添加离子参考:没有Ionic一切正常,在控制台中没有固有错误,与离子我得到两个错误

应用程序启动时:

"Error in Success callbackId: App1084986710 : Error: Unknown event action undefined", source: file:///android_asset/www/default/worklight/cordova.js (309)

点按后退按钮(来自第2页)

W/UnimplementedWebViewApi(21373): Unimplemented WebView method onKeyDown called from: android.webkit.WebView.onKeyDown(WebView.java:2389)

更新

如果我从js函数中删除WL.App.overrideBackButton(goBack);WL.App.resetBackButton();,则两个错误仍然存​​在,并且点按后退按钮时应用仍会崩溃。

如果我链接/包含Ionic css和js但删除任何Ionic内容(没有ng-app属性,没有来自index.html的app.js引用),后退按钮覆盖工作正常。

的index.html

<!DOCTYPE HTML>
<html style="height:100%" ng-app="myTryOut" id="content">
    <head>
        <meta charset="UTF-8">
        <title>TryOut</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">

        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/ionic.css">
        <link rel="stylesheet" href="css/ionicons.css">
        <script>window.$ = window.jQuery = WLJQ;</script>
    </head>
    <body onload="initLoad()">
    <div id="container">
    <!-- content will be loaded here -->

    </div>

        <script src="js/main.js"></script>
        <script src="js/messages.js"></script>
        <script src="js/initOptions.js"></script>
        <script src="js/ionic-bundle.js"></script>
        <script src="js/app.js"></script>
    </body>
</html>

page1.html

<!DOCTYPE html>
<html>
    <h2>Page 1</h2>
    <button class="button button-block button-assertive" onclick="goToPage2()">Go</button>
</html>

page2.html

<!DOCTYPE html>
<html>
    <h2>Page 2</h2>
    <button class="button button-block button-assertive" onclick="goBack()">Back</button>
</html>

main.js

function wlCommonInit(){

}

function initLoad() {
    goBack();
}

function goToPage2() {
    $("#container").load("html/derp.html",function(){
        console.log("I'm in page 2");
        WL.App.overrideBackButton(goBack);
    });
}

function goBack() {
    $("#container").load("html/dorp.html",function(){
        console.log("I'm in page 1");
        WL.App.resetBackButton();
    });
}

app.js

var myModule = angular.module('myTryOut', ['ionic']);

1 个答案:

答案 0 :(得分:0)

抱歉,我一直很忙。为了清晰起见,我在这里写下所要求的测试结果。

我按顺序尝试了:

1 - 处女MFP应用程序(新的MF项目 - &gt;运行为... - &gt;在MF服务器上运行 - &gt;构建APK)

2 - 将main {j}和onload事件的myOverride()函数添加到index.html中的body标签中(参见下面的代码)

3 - 处女&#34; Hello Mobile First&#34; app引用了Ionic源文件,但没有Ionic登录(即body元素上没有ng-app属性)

4 - 处女&#34; Hello Mobile First&#34;具有后退按钮覆盖代码的应用程序(如上所述),对Ionic源文件的引用,但没有Ionic登录(即body元素上没有ng-app属性)。

5 - 处女&#34; Hello Mobile First&#34;具有后退按钮覆盖代码的应用程序(如上所述),对身体元素的Ionic源文件和ng-app属性的引用。

在启动应用程序的所有5个案例中我在LogCat中遇到了这些错误:

04-11 17:09:19.260: W/CordovaPlugin(910): Attempted to send a second callback for ID: StatusBar959874445
04-11 17:09:19.260: W/CordovaPlugin(910): Result was: "Invalid action"
04-11 17:09:19.400: I/chromium(910): [INFO:CONSOLE(309)] "Error in Success callbackId: App959874446 : Error: Unknown event action undefined", source: file:///android_asset/www/default/worklight/cordova.js (309)

两次

04-11 17:09:20.300: W/CordovaPlugin(910): Attempted to send a second callback for ID: StatusBar506640404
04-11 17:09:20.300: W/CordovaPlugin(910): Result was: "Invalid action"
04-11 17:09:20.310: I/chromium(910): [INFO:CONSOLE(309)] "Error in Success callbackId: App506640405 : Error: Unknown event action undefined", source: file:///android_asset/www/default/worklight/cordova.js (309)

04-11 17:09:20.380: E/AndroidProtocolHandler(910): Unable to open asset URL: file:///android_asset/www/default/worklight/messages/it-IT/messages.json

点击后退按钮时,我会收到以下错误:

04-11 17:13:38.300: E/BD.Reporter(782): Can't getService HwBDService
04-11 17:13:38.360: W/IInputConnectionWrapper(910): showStatusIcon on inactive InputConnection
04-11 17:13:38.370: W/System.err(662): java.lang.NullPointerException: Attempt to invoke virtual method 'int com.huawei.lcagent.client.LogCollectManager.getUserType()' on a null object reference

04-11 17:13:38.300: E/BD.Reporter(782): Can't getService HwBDService
04-11 17:18:58.680: W/UnimplementedWebViewApi(2338): Unimplemented WebView method onKeyDown called from: android.webkit.WebView.onKeyDown(WebView.java:2389)

每当没有离子逻辑(情况2和4)实现后退按钮覆盖时,应用程序行为正确(即显示警报并且不退出/崩溃)。在案例5中,会显示警报,但随后应用退出。

//// main.js ////
function myOverride() {
    WL.App.overrideBackButton(function(){
        alert("you pressed the back button!");
    });
}

无论如何,这看起来非常简单,如果您可以在最后测试它并查看它是否表现相同,我会很感激。我想这也比这种混乱更清楚......