带有android后退按钮行为的worklight

时间:2015-04-30 06:57:15

标签: ibm-mobilefirst

我需要你的帮助,我们目前正在使用worklight混合应用程序并使用sencha框架,我们需要在用户按下android后退按钮时触发。实际上,在我需要关闭应用程序之后,我试图从我的设备获得警报。 我们目前收到警告YES或NO确认消息显示在设备上。如果我单击是表示我想要关闭或最小化应用程序。在我试过的代码下面。如何使用worklight API关闭应用程序?

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
            <ContentTemplate>
                <asp:Table class="mel-table" style="text-align: center" runat="server" id="mytab1">
                    <asp:TableRow>
                        <asp:TableCell>Case Number :</asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox ID="caseNumber" runat="server"></asp:TextBox>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
                <asp:Button OnClick="btnOK1_Click" ID="btnOK1" runat="server" Text="Save" />
            </ContentTemplate>
        </asp:UpdatePanel>

--------------------------------------------------------------------------------------------------------

Public Partial Class _Default
    Inherits System.Web.UI.Page

    Private listCaseNo As List(Of Double) = Nothing

    Protected Sub Page_Init(sender As Object, e As EventArgs)

    End Sub


    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If ViewState("ListCases") IsNot Nothing Then
            listCaseNo = DirectCast(ViewState("ListCases"), List(Of Double))
        Else
            listCaseNo = New List(Of Double)()
        End If

        ReloadRows()
    End Sub

    Public Function checking() As Boolean

        Dim caseNo As Double = 0
        Try
            caseNo = Convert.ToDouble((caseNumber.Text).Trim())
        Catch ex As Exception
            caseNo = 0
        End Try

        Dim r As New TableRow()
        Dim c0 As New TableCell()
        r.Cells.Add(c0)

        Dim but As New LinkButton()
        but.ID = Convert.ToString(caseNo)
        but.Text = caseNo.ToString()
        AddHandler but.Click, AddressOf LinkButton1_Click
        c0.Controls.Add(but)

        mytab1.Rows.Add(r)

        listCaseNo.Add(caseNo)

        ViewState("ListCases") = listCaseNo

        Return True
    End Function


    Private Sub ReloadRows()
        For Each objCase As var In listCaseNo
            Dim r As New TableRow()
            Dim c0 As New TableCell()
            r.Cells.Add(c0)

            Dim but As New LinkButton()
            but.ID = Convert.ToString(objCase)
            but.Text = objCase.ToString()
            AddHandler but.Click, AddressOf LinkButton1_Click
            c0.Controls.Add(but)

            mytab1.Rows.Add(r)
        Next
    End Sub

    Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
        'My Code here

    End Sub


    Protected Sub btnOK1_Click(sender As Object, e As EventArgs)


        If (checking()) Then
        End If

    End Sub

End Class

由于 karthik E

1 个答案:

答案 0 :(得分:2)

在Android和iOS中,不再考虑退出应用程序,应该以编程方式执行此操作。这是一个必须由最终用户明确完成的动作。

意思是,在应用程序“关闭”后,最终用户必须使用打开应用程序列表的物理/软件按钮,并通过从列表中滑动应用程序退出应用程序。

这有效:

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() {}}
             ]
    );
}