Skip to Content
0
May 04, 2015 at 08:58 AM

How to get current view name on clicking device back button?

889 Views

Hi,

iam wriing a function for handling device back button(in android) press in my app.controller.js .How to get current viewname when clicking device back button.

code samples will be helpful.

my app.controller.js looks like below

sap.ui.controller("com.opensap.App", {

onInit : function() {

document.addEventListener("deviceready", onDeviceReady, false);

},

onBeforeShow : function(evt) {

},

navButtonTap : function(evt) {

}

});

function onBackKeyDown(){

//alert("hai");

//sap.ui.getCore().byId("SalesDetail").app.backToPage("ProductList");

//sap.ui.getCore().byId("ProductList").app.backToPage("Dashboard");

//sap.ui.getCore().byId("SupplierDetail").app.backToPage("Dashboard");

}

function onDeviceReady(){

document.addEventListener("backbutton", onBackKeyDown, false);

}