Android: windows are not showing up on screen!

You must Login before you can answer or comment on any questions.

Hi,

I've got an app which I tested on my Galaxy S2, iPad, iPhone and on iOS emulators. I didn't test it on Android Emulator mostly because it would hang my mac too often. Everything worked fine and cool. The app consists of one window, which is a heavy weight one. Then you've got labels which act like buttons. You click on a label and a new window [not heavy weight] is opened with another set of labels. More or less a simple app.

Yesterday I've installed the app on a Galaxy Ace phone. I've started it and ... nothing showed up. I've tried reopening - same thing. On 3rd attempt my app showed up and worked ok. On 4th attempt it didn't. Quite random. I've tried checking logs - nothing. All of my debug logs show that everything is created.

Today I've tried testing on android emulator Same thing. From time to time it would show up, but usually it does not.

I've tried narrowing down the issue, and it seems it's got to do with the lightweight windows. When I have my heavyweight and open a lightweight with some labels on it, it will not show up. When I have heavyweight and add a view with some labels on it, it will show up.

Also I was able to spot something weird. It kind of looks like the lightweight window is opened BEHIND the heavyweight window. When pressing back button on the emulator I was able to see the content I've created after the main window was removed from screen. Weird.

So I decided to wrap the code in a function and use setTimeout to run it after a second. This helped. When the heavyweight window was settled on screen the lightweight would cover it. However if I try to open them at the same time, the lightweight will be opened behind the heavyweight.

Could anyone explain to me why would this happen?

I don't want to use setTimeout to programmatically slow down my application.

Some code:

This works:

var self = Ti.UI.createWindow({
        backgroundColor : '#00ffff',
        fullscreen : true,
        navBarHidden : true,
        exitOnClose : true,
    });
 
        var view = Ti.UI.createView();
 
 
        var registration = Ti.UI.createLabel({
            color : '#000000',
            text : 'register',
            center : {
                x : 50, //Ti.Platform.displayCaps.platformWidth * 0.5,
                y : 50, //Ti.Platform.displayCaps.platformHeight * 0.5,
            },
            font : {
                fontSize : "40dp",
            },
            minimumFontSize : "16dp",
            width : Ti.Platform.displayCaps.platformWidth * 0.7,
        })
        view.add(registration)
 
        self.add(view)
 
self.open()
This works:
var self = Ti.UI.createWindow({
        backgroundColor : '#00ffff',
        fullscreen : true,
        navBarHidden : true,
        exitOnClose : true,
    });
self.open()
 
function test() {
        var view =  Ti.UI.createWindow({
        backgroundColor : '#ffff00'
    });
 
 
        var registration = Ti.UI.createLabel({
            color : '#000000',
            text : 'register',
            center : {
                x : 50, //Ti.Platform.displayCaps.platformWidth * 0.5,
                y : 50, //Ti.Platform.displayCaps.platformHeight * 0.5,
            },
            font : {
                fontSize : "40dp",
            },
            minimumFontSize : "16dp",
            width : Ti.Platform.displayCaps.platformWidth * 0.7,
        })
        view.add(registration)
 
        view.open()
}
 
setTimeout(test, 900)
This does not:
var self = Ti.UI.createWindow({
        backgroundColor : '#00ffff',
        fullscreen : true,
        navBarHidden : true,
        exitOnClose : true,
    });
self.open()
        var view =  Ti.UI.createWindow({
        backgroundColor : '#ffff00'
    });
 
 
        var registration = Ti.UI.createLabel({
            color : '#000000',
            text : 'register',
            center : {
                x : 50, //Ti.Platform.displayCaps.platformWidth * 0.5,
                y : 50, //Ti.Platform.displayCaps.platformHeight * 0.5,
            },
            font : {
                fontSize : "40dp",
            },
            minimumFontSize : "16dp",
            width : Ti.Platform.displayCaps.platformWidth * 0.7,
        })
        view.add(registration)
 
        view.open()

1 Answer

Accepted Answer

After playing with your code for a bit, it seems that there might be issues with opening a non-fullscreen window over top of a fullscreen window.

If you set fullscreen : true in the second window, it comes up. Although when you close it, you get a brief flash of the splash screen, so that's not ideal.

I'm not sure what you're trying to accomplish, but you might want to look at Kevin Whinnery's cross-platform Navigation Controller to manage your windows.

BTW: I noticed that you have a lot of trailing commas in your code, e.g.

{
        backgroundColor : '#00ffff',
        fullscreen : true,
        navBarHidden : true,
        exitOnClose : true,    // should not have a comma
    }
This is generally bad form; you may get away with it most of the time, but it will eventually burn you, either in Titanium or in web development.

— answered 10 months ago by Jason Priebe
answer permalink
2 Comments
  • Thanks a lot! I will take a look at the navigation controller. I was unable to find any documentation for it, hopefully code will be self explanatory. Thanks for pointing the trailing comma... Currently I use a lot of Lua/Groovy and got used to their syntax ;)

    — commented 10 months ago by Krystian Szczesny

  • Here's a Forging Titanium episode that presents the controller.

    BTW -- if you find the answers helpful, please mark question as answered. Thanks!

    — commented 10 months ago by Jason Priebe

Your Answer

Think you can help? Login to answer this question!