Project: titanium
Issue TIMOB-15253: Android: singleTask launchMode with HeavyWeight window hangs after 1st launch
When launching your app with it's main activity set to {{android:launchMode="singleTask"}} and it's main window a HeavyWeight one, it will hang on the second and every following launch. This bug blocks me from allowing users to open my app by using an URL scheme on a webpage or in a email message, send to them when they lost their password, received an invite to play a game etc. h1. Why use launchMode? By default, when launching your app via another app, e.g. using an URL scheme in the browser, your apps main activity will be stacked onto the current app's task. If your app was already running in the background, you will have 2 instances of the app running. Android has a [launchMode|http://developer.android.com/guide/topics/manifest/activity-element.html#lmode] attribute that allows you to instruct the OS to always open the activity as the root of a new task, using {{singleTask}} as value. This works fine, but not when the app's main window is HeavyWeight, for example a {{Ti.UI.TabGroup}} or a {{Ti.UI.Window}} with {{modal:false}}. h1. To reproduce # Create a new project: {{titanium create -p android -n test}} # Build (only) to generate manifest: {{titanium build -b -p android}} # Open the generated {{build/android/AndroidManifest.xml}} and copy the first {{}} tree to the {{tiapp.xml}} under {{ti:app/android/manifest/application}}. You will need to create the empty {{}} and {{}} elements yourself. # Add {{android:launchMode="singleTask"}} to the {{}} element and save {{tiapp.xml}}. # Build the app to the device: {{titanium build -p android -T device}} # Open the updated {{AndroidManifest.xml}} to confirm the only effective change is the newly added attribute. # Seeing the app properly launched on the device, move it to the background by clicking the device's home button. # Lookup the app on the device and launch it again. You'll see a black screen with a titlebar ({{test}}) only. # Now replace the app's {{app.js}} with a lightweight window instead of the default heavyweight tabgroup: {code} Ti.UI.createWindow({backgroundColor:'white'}).open(); {code} # Repeat steps 5-8 and this time, the app will properly launch.
Story points: 8