[TIMOB-18631] Android: AlertDialog.show() causes crash
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2015-03-12T22:12:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Leor Brenman |
Assignee | Hieu Pham |
Created | 2015-03-03T00:19:13.000+0000 |
Updated | 2016-02-12T19:15:49.000+0000 |
Description
AlertDIalog show() causes crash on Android but OK on iOS
I have a demo app that i am creating and want to show() and AlertDialog on a button click to confirm the user's action.
I am following the code example in the online docs and it works fine on iOS. On Android it will work once or twice and then on the 3rd or fourth time, it causes a fatal crash (logs attached).
Ricardo has the project and can help anyone in Mountain View.
TEST ACCOUNT LOGIN:
username: a
password: 1234
When I use the same code in a simpler Hello World app it works fine on iOS and Android.
Attachments
[~ralcocer] Can we extract this out into a test case to attach to the ticket?
Leor created a minimalist test case but it's not giving any errors. It appears to be a combination of factors, but the patterns [~lbrenman] is using are not really unusual. I suppose I could post the whole project for review, if [~lbrenman] is fine with that.
I am fine with that :)
The project has modules and whatnot, so it exceeds the size allowed by Jira, but can be downloaded from : http://sht.tl/iS9rrP . [~lbrenman] created a test user "a" with password "1234".
I've looked at the code but not tested it yet. You are creating an AlertDialog in the XML and showing it later. The AlertDialog is not meant to be used like that, it's meant to be created, shown, and garbage collected. Try creating the alert in code and showing it as soon as it's created. Create one instance per "show" that you need. They're not meant to be recycled.
That will be great if this is the case and i will check this out. However, i copied this code directly from our API docs at: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.AlertDialog Are the docs wrong or did i misinterpret the docs?
Your suggestion worked!! Thanks. I think we need to convert this to a document JIRA because the documentation does not clearly explain this and implies that you can implement via XML and js. If you agree can you convert this to a documentation bug or i can, but will defer to your advice.
Fixed controller with Pedro's suggested fix
Unable to reproduce with this test case
I analyzed the log and there wasn't any log indicating a crashing error from Titanium that is app related. Since I can't reproduce this issue, I'll resolve it. Please feel free to reopen if you have more information, though it looks like your problem is solved.
Pedro Enrique, I'm extremely confused here. Are we supposed to use it with XML or not? You state we are not supposed to, but as Leor Brenman says, the documentation even gives an example of how to use it with XML. Looks like I'm also getting this crash on devices with low memory.