Titanium device back button not closes my application properly - android

I am working Android mobile application using Titanium studio.I have developed small application.After logging into application will display two tabs on my new window; after clicking any other tab it opens correct window.But when I click device back button (back button on my android phone simulator) it not closes my application. it render one blank window and if I again click back button it closes my application
after log in successful I used window-name.close(); so that it not render again sign in form. But I am using .close() for only sign in window so that after clicking back it will not show sign in page again.
var user1 = Ti.UI.createWindow
({
navBarHidden : false,
url:'main.js',
});user1.open();
w.close();
home.close();
========== main=============
var mainTabGroup = Titanium.UI.createTabGroup();
var feedWin = Titanium.UI.createWindow({
url:'home/feed.js'
});
var feedTab = Titanium.UI.createTab({
title:'Feed',
window:feedWin
});
var listWin = Titanium.UI.createWindow({
url:'home/list.js'
});
var listTab = Titanium.UI.createTab({
title:'List',
window:listWin
});
mainTabGroup.addTab(feedTab);
mainTabGroup.addTab(listTab);
mainTabGroup.open();

you need to set
exitOnClose:true
on whichever window you want to trigger the closing of the app when that window is closed
From the appcelerator documentation, Titanium.UI.Window
(Android only.) Boolean indicates if the application should exit when
the Android back button is pressed while the window is being shown.
You can only set this as a createWindow({...}) option. Setting it
after window creation will no effect.

Related

Back button getting disappear in android device ionic2

I am facing issue of back button disappearing in my ionic2 app.
below are the steps after which issue is occuring
Main screen - click on icon (page 1)
2.popover will come with 3 choices (popover - page 2)
3.select any option and new page will open (here back button is visible-page 3 ) click on '+' and go to new page(page 4)
4.come back to page 3 and back button is getting disappeared.
I have not written any specific code to show / hide back button as its working properly as per the default behaviour this issue only happening on android device not on ios. how to solve this?
import { App } from 'ionic-angular';
constructor(public navCtrl: NavController public appCtrl: App) {
}
function(){
this.appCtrl.getRootNav().navCtrl.push(strPagename,{params:
params});
}
Read about navigation with overlay components here like modals ,popover,etc.
https://ionicframework.com/docs/api/navigation/NavController/
Also getRootNav will be deprecated soon and we should use getRootNavById

white screen after exitApp

I am developing mobile app with ionic having splash & launch screen.
As of now, I am using below code to do my configurations & initiations and then hiding my splash screen.
angular.element(document).ready(function () {
// config & initiations
ionic.Platform.ready( function() {
if(navigator && navigator.splashscreen){
navigator.splashscreen.hide();
}
});
});
Also, I am using double tap exit at first launch page with below snippet.
.factory('backcallFactory', ['$state','$ionicPlatform','$ionicHistory','$timeout',function($state,$ionicPlatform,$ionicHistory,$timeout){
var obj={}
obj.backcallfun=function(){
var backbutton=0;
$ionicPlatform.registerBackButtonAction(function () {
if ($state.current.name == "register") {
if(backbutton==0){
backbutton++;
window.plugins.toast.showShortCenter('Press again to exit');
$timeout(function(){backbutton=0;},5000);
}else{
navigator.app.exitApp();
}
}
else{
$ionicHistory.goBack();
}
}, 100);
}
return obj;
}])
So in launch page, if i click back button twice in 5 seconds and it gets closed.
I could see app is still open in open apps list. (first or last button in android phones).
The problem is, if I relaunch the app after double tap to exit , then it is showing white screen for a while and showing launch screen (but no splash screen). I checked in other popular apps having double tap to exit function are showing splash screen again and launch screen without white screen.
How can I achieve the same in my app.
I had the same issue. It works fine by downgrading to version 2.0.0 of cordova-plugin-splashscreen.
You can refer to https://issues.apache.org/jira/browse/CB-9374.

Ionic framework, how to deny to hide alertPopup by back button on the Android?

on home page of my app is displayed Ionic alertPopup message during the first run.
User should not be able to hide this alertPopup by back button (he should always tap on the button).
var alertPopup = $ionicPopup.alert({
title: title,
template: message
});
How can i do it please ?
Many thanks for any advice.
I found the solution in using
$ionicPlatform.offHardwareBackButton
and
$ionicPlatform.onHardwareBackButton
http://ionicframework.com/docs/api/service/%24ionicPlatform/

How Removing window from a tab in titanium?

I am using titanium appecelerator to build an app in both ios and android.
I use the following code to create a tab group and add a tab to it.
var localTabGroup = Ti.UI.createTabGroup();
var planTab = Ti.UI.createTab({
title : NYC.Common.StringConstant.TAB_TITLE_PLAN,
icon : NYC.Common.ResourcePathConstant.IMG_TAB_PLAN,
window : planTabWin
});
localTabGroup.open();
And call the following function to create a window and add it to the tab
addWindowToTabGroup : function(window) {
tabGroup.activeTab.open(window, {
animated : true
});
},
Now, I often have to remove window from the stack of the tab ( eg: on android back button or ios navigation bar back)
Till now, I use window.close() to remove the window from the stack . But, it always shows warnings like.
[ERROR][TiBaseActivity( 378)] (main) [3320,4640528] Layout cleanup.
[WARN][InputManagerService( 62)] Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#406e4258
I was just wondering if I am following the correct approach? Or is there a better way to remove a window from the tab?
Thanks.
Tabs behave a lot differently on iOS and Android, On Android, the tab does not maintain a stack of windows. Calling open opens a new, heavyweight window, which by default covers the tab group entirely.This is very different from iOS, but it is for Android applications. Users always use the Back button to close the window and return to the tab group.
This may be happening because you are trying to remove the window even though natively Android already removes it. Check out the Android Implementation Notes of the docs here
To completely eliminate this problem, I would just open up a modal window without using the TabGroup, this would be more cross platform:
addWindowToTabGroup : function(window) {
window.open({
modal : true,
animated : true
});
}
This will open a modal window which behaves the same on both platforms, and can be handled easily by the native back button functionality.

android:back (device back button) event in Titanium not working

Hi i am working on android application development.I am using Titanium studio for development. I create a simple application.I want to capture the device back button event in my application because I don't want to user android default tabs in titanium.I am creating my own tabs.I tried following code :
:list.js
var expt = Titanium.UI.currentWindow;
expt.addEventListener('android:back', function (e)
{
Ti.App.fireEvent('expt_back_event');
});
:app.js
Ti.App.addEventListener('expt_back_event',function(e)
{
alert('hiiii in side event listener');
});
But its not working instead of giving pop-up it closed my application which I don't want. Is there any way to obtain this result.
You have to cancel the bubble of the event.
mainWindow.addEventListener('android:back', function(e) {
e.cancelBubble = true;
Ti.App.fireEvent('android_back_button');
});

Categories

Resources