I've installed my simple demo app (empty project with single window template) via USB on my android device. When I start the app I'll see the titanium splash, then the window of the app appears very quickly and after that the app shutdown automatically. Can anybody help me with this behaviour?
4 Answers
Accepted Answer
HI Alexander, i just created a single window application in titanium and it shows the the file and function structure you are using and presenting here... i run it on both the systems.. iOS and android. it runs without error.
so you can try that too... create a default single window application and run on android... i tried on both android emulator and device..
You're doing something funny there :) post the code in a pastie and show us what u're doing.
I have no special code. Just a new created project of the template "Single Window Application". Here it is: app.js:
/* * Single Window Application Template: * A basic starting point for your application. Mostly a blank canvas. * * In app.js, we generally take care of a few things: * - Bootstrap the application with any data we need * - Check for dependencies like device type, platform version or network connection * - Require and open our top-level UI component * */ //bootstrap and check dependencies if (Ti.version < 1.8 ) { alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later'); } // This is a single context application with mutliple windows in a stack (function() { //determine platform and form factor and render approproate components var osname = Ti.Platform.osname, version = Ti.Platform.version, height = Ti.Platform.displayCaps.platformHeight, width = Ti.Platform.displayCaps.platformWidth; //considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide //yourself what you consider a tablet form factor for android var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899)); var Window; if (isTablet) { Window = require('ui/tablet/ApplicationWindow'); } else { // Android uses platform-specific properties to create windows. // All other platforms follow a similar UI pattern. if (osname === 'android') { Window = require('ui/handheld/android/ApplicationWindow'); } else { Window = require('ui/handheld/ApplicationWindow'); } } Ti.API.info('app.js open window'); new Window().open(); Ti.API.info('app.js window opened'); })();ui\handheld\android\ApplicationWindow.js
//Application Window Component Constructor function ApplicationWindow() { Ti.API.info('ApplicationWindow ENTER'); //load component dependencies var FirstView = require('ui/common/FirstView'); //create component instance var self = Ti.UI.createWindow({ backgroundColor:'#ffffff', navBarHidden:true, exitOnClose:true }); //construct UI var firstView = new FirstView(); self.add(firstView); Ti.API.info('ApplicationWindow LEAVE'); return self; } //make constructor function the public component interface module.exports = ApplicationWindow;ui\commonFirstView.js
//FirstView Component Constructor function FirstView() { Ti.API.info('FirstView ENTER'); //create object instance, a parasitic subclass of Observable var self = Ti.UI.createView(); //label using localization-ready strings from <app dir>/i18n/en/strings.xml var label = Ti.UI.createLabel({ color:'#000000', text:String.format(L('welcome'),'Titanium'), height:'auto', width:'auto' }); self.add(label); //Add behavior for UI label.addEventListener('click', function(e) { alert(e.source.text); }); Ti.API.info('FirstView LEAVE'); return self; } module.exports = FirstView;There are no changes in automatically generated code
Can anybody help me with this problem?
Your Answer
Think you can help? Login to answer this question!