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.
Related
I am running the latest Xamarin Forms on VS 2019 community edition.
I just started the basic Xamarin Forms project and added a Flyout page template to it.
When running this on the Android emulator it works fine, but the menu won't close after selecting a page.
The code has not changed apart from adding another page to the menu items.
The code isPresented = false is still there but has no effect whatsover.
Is it simply not possible to have the menu collapse in landscape mode? Then what are my alternatives?
You just have to add in the MenuPage (the main file, the first one that is generated) the following property:
FlyoutLayoutBehavior = "Popover"
public MasterMenuItem ()
{
InitializeComponent ();
MasterBehavior = MasterBehavior.Popover; // This solve my problem
}
Goal: From a website having a lot of links, I will usually middle click the ones I want. Firefox will open them in background new tabs on the side. Now I want to do the same from my Android tablet where middle click is not available.
1) Best: Is there an easy way to middle click on a tablet ?
2) Otherwise something better than a long press to simulate right click then open in new tab ?
3) I'm currently trying a TamperMonkey solution based on other questions found here:
link.addEventListener('click', function(event){event.preventDefault();return newBackgroundTab(this);}, false);
function newBackgroundTab(node) {
var newWindow = window.open("about:blank", "_blank");
newWindow.blur();
window.focus();
newWindow.location.href = node.href;
return false;
}
It also need to set the dom.disable_window_flip option to false in Firefox.
This works on desktop, but not on Android, focus stays on the new tab even though the disable option was already on false by default.
Working on a Project and stuck in an Issue:
Hardware Back Button Reloading Application (I am using Angular Router in this application).
My Code to Exit Application:
ionViewDidEnter(){
this.subscription = this.platform.backButton.subscribe(()=>{
navigator['app'].exitApp();
});
}
ionViewWillLeave(){
this.subscription.unsubscribe();
}
While same logic Working in other applications. but in this application its reloading the application not exiting it.
P.S: i have also tried it to put in platform.ready() but no luck.
With IONIC 4, there is new method subscribeWithPriority developed to handle race between soft & hard back button. Try modifying your code like below:
this.platform.backButton.subscribeWithPriority(1, () => {
navigator['app'].exitApp();
});
subscribeWithPriority() stops the propagation of the event after its execution and if we subscribe with high priority and execute our prefered navigation instead of default one then it is going to work as you want.
More reference docs for details:
https://github.com/ionic-team/ionic/commit/6a5aec8b5d76280ced5e8bb8fd9ea6fe75fe6795
https://medium.com/#aleksandarmitrev/ionic-hardware-back-button-nightmare-9f4af35cbfb0
UPDATES:
Try using this new version of exitApp cordova plugin. I haven't
tried myself but looks promising from popularity.
Also try to empty the page stack from Navcontroller or go to your home screen, seems like that's causing the reload for app with sidemenu's & tab pages... this.navCtrl.pop() / this._navCtrl.navigateBack('HomeScreen'), and then call exitApp.
NOTE: Tabs & SideMenu as those have its own routing module does create lot of complexity with app navigation.
Solved:
As Mention by #rtpHarry template of SideMenu / Tabs have History which leads application to Reload it self on root page. i was able to solve this by clearing History.
ionViewDidEnter(){
navigator['app'].clearHistory();
}
on Your Root Page just Clear your history and your Hardware Back Button will close the Application instead of Reloading it.
Do you have a sidemenu in your app? I'm just curious because this seems to be when I get this problem as well.
If you look in your inspector, you will see that window.history has a length of 1.
I don't see it in some of my apps, but the app that I have a side menu setup acts this way - on the homepage if you press back the screen goes white then it reloads the app.
Like I say, looking in the inspector shows that there is a history to step back to, which it is trying to do, and whatever that history step is, it just pushes it forward back to the homepage, which made me wonder if it was the sidemenu setting up its own control of the navigation system.
I've probably said some poorly worded terminology but as I haven't solved this myself I thought I would just let you know what I had found... hopefully it helps you move forward.
In my scenario, I wasn't even trying to do the exit on back code - I just noticed that the app would appear to "reboot" if I kept pressing back.
This explain the solution on Ionic 5 (and 4.6+ too I think).
private backButtonSub: Subscription;
ionViewDidEnter() {
this.backButtonSub = this.platform.backButton.subscribeWithPriority(
10000,
() => {
// do your stuff
}
);
}
ionViewWillLeave() {
this.backButtonSub.unsubscribe();
}
also keep
IonicModule.forRoot({
hardwareBackButton: true
}),
to true (default) in your app.module.ts
Sources:
https://www.damirscorner.com/blog/posts/20191122-CustomizingAndroidBackButtonInIonic4.html
The Doc
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
I making application for Android and ipone using titanium sdk in which i have used tabgroup.but when i go from one one screen to another screen in same tab.tab is dissable in second screen while it is visible i iphone device not in Android device.
I have used fiollwing codeto go from main window to inner window in same tab.
**
Continue.addEventListener('click',function(e)
{
var win = Titanium.UI.createWindow({
url:'tab1_continue.js',backgroundColor:'#fff'
});
Titanium.UI.currentTab.open(win,{animated:true});**
it does not work on android.plz help
The "url" property is causing the window to be heavyweight, which means it cannot be a child of the tab group (it necessarily takes up everything). Read more on the discussion in the Appcelerator Q&A about this topic.
if this is in "app.js" then use this code
Continue.addEventListener('click',function(e){
var win = Titanium.UI.createWindow({
url:'tab1_continue.js',backgroundColor:'#fff'
});
<tabName>.open(win,{animated:true});**
});
otherwise
Continue.addEventListener('click',function(e){
var win = Titanium.UI.createWindow({
url:'tab1_continue.js',backgroundColor:'#fff'
});
Titanium.UI.currentTab.open(win,{animated:true});
});