[TIMOB-17715] Android: Cannot open new window after last window closes
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-09-18T17:39:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | android, regression |
Reporter | Caleb Cox |
Assignee | Ping Wang |
Created | 2014-09-17T02:17:18.000+0000 |
Updated | 2017-03-22T21:51:21.000+0000 |
Description
After closing the last window on Android, when attempting to open a new window, the app crashes with the "Unfortunately app has stopped" message. Here is the stack trace that I get:
{noformat}
E/AndroidRuntime( 2450): FATAL EXCEPTION: main
E/AndroidRuntime( 2450): Process: com.appdev.test, PID: 2450
E/AndroidRuntime( 2450): java.lang.NullPointerException
E/AndroidRuntime( 2450): at android.content.ComponentName.(ComponentName.java:77)
E/AndroidRuntime( 2450): at android.content.Intent.(Intent.java:3813)
E/AndroidRuntime( 2450): at ti.modules.titanium.ui.WindowProxy.handleOpen(WindowProxy.java:128)
E/AndroidRuntime( 2450): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:88)
E/AndroidRuntime( 2450): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:399)
E/AndroidRuntime( 2450): at android.os.Handler.dispatchMessage(Handler.java:98)
E/AndroidRuntime( 2450): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 2450): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 2450): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2450): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 2450): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 2450): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 2450): at dalvik.system.NativeStart.main(Native Method)
{noformat}
Here is the test case that I am using:
var openWindow = function(index) {
var window = Ti.UI.createWindow({
backgroundColor: 'white',
title: 'Window ' + index
});
var button = Ti.UI.createButton({
width: 80,
height: 40,
title: 'Button'
});
button.addEventListener('click', function() {
window.close();
openWindow(index + 1);
});
window.add(button);
window.open();
};
openWindow(1);
It successfully closes the first window but crashes when attempting to open the second window. It works when opening the second window before closing the first.
May I ask what classifies this as a regression? Did it previously work in an earlier version of the SDK?
Yes, the exact same code runs without crashing using Titanium SDK 3.2.3. Sorry for not explicitly mentioning that earlier.
[~pwang] can you please take a look?
Starting from 3.3.0, we set exitOnClose to true by default for the first window (see [PR#5602](https://github.com/appcelerator/titanium_mobile/pull/5602)), which means once the first window is closed the whole application is closed. That's why the app crashes when you open the second window. To make the above test case run, we can modify it
I verified that the change you suggested fixes my issue. Thanks for your help! Someone should update the documentation to reflect the new default value of exitOnClose.
This change has been in the 3.3.0 Release Notes. Will update the default value of exitOnClose. PR: https://github.com/appcelerator/titanium_mobile/pull/6127 3_4_X PR: https://github.com/appcelerator/titanium_mobile/pull/6128 Resolved the ticket as invalid.
Closing ticket as invalid with reference to previous comments.