on 2013 Oct 13 11:55 AM
have a sapui5 mobile application which runs perfectly. The android device has a back button. What I want to achieve is that when you press the button the app should navigate back. In the sapui5 mobile api it is possible with this coding:
app.back();
The question now is how I can make this? The activity of my android application has the following method:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
//Here you should navigate one view back
}
return super.onKeyDown(keyCode, event);
}
Is it possible to call from my activity the app variable in javascript and then tell my application to navigate back?
Greetings Stef
Hi Stef,
check out following page https://sapui5.hana.ondemand.com/sdk/docs/guide/Navigation.html- and even better, start reading from here https://sapui5.netweaver.ondemand.com/sdk/docs/guide/BestPractice.htmlfocusing on the Navigation sample.
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sergio,
so you mean by adding the following coding the navigation with my back-button works?
sap.ui.controller("view.App", {
onInit : function() {
jQuery.sap.history({
routes: [{
// This handler is executed when you navigate back to the history state on the path "page"
path : "page", handler: jQuery.proxy(historyPageHandler, this)
}],
// The default handler is executed when you navigate back to the history state with an empty hash
defaultHandler: jQuery.proxy(historyDefaultHandler, this)
}); ...
sap.ui.controller("view.App", {
...
navTo : function(id, writeHistory, navType, data) {
...
// write history
if (writeHistory === undefined || writeHistory) {
jQuery.sap.history.addHistory("page", {id: id}, false);
}
Greetings
Stef
Hi everybody,
I found a solution for solving the problem ... I wrote a new javascript file with the following code:
function onBackKeyDown(){
// Handle here the BackButton
}
function onDeviceReady(){
document.addEventListener("backbutton", onBackKeyDown, false);
}
function init(){
document.addEventListener("deviceready", onDeviceReady, false);
}
I took this out of the phonegap api and works perfectly! Thanks for all of your help!
Greetings
Stef
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.