我正在尝试让我的应用程序存储并恢复它所在的屏幕,当应用切换到原生相机或其他应用时。它似乎适用于Android,但不会触发iOS。
初始化:function(){
this.bindEvents();
},
bindEvents: function() {
console.log("Binding Events");
document.addEventListener('deviceready', this.onDeviceReady, false);
document.addEventListener('pause', this.onPause, false);
document.addEventListener('resume', this.onResume, false);
onPause: function() {
// Here, we check to see if we are in the middle of taking a picture. If
// so, we want to save our state so that we can properly retrieve the
// page url in onResume().
window.localStorage.setItem(APP_STORAGE_KEY, window.location.href);
console.log(window.location.href);
},
onResume: function(event) {
// Here we check for stored state and restore it if necessary.
setTimeout(function(){
var storedState = window.localStorage.getItem(APP_STORAGE_KEY);
if(storedState) {
console.log(storedState);
window.location.href=storedState;
}
},0);
},