| Issue 32: | [android] Alert without a type exits application | |
| 2 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Create midlet with:
Alert aAlert = new Alert("Test");
Display.getDisplay(this).setCurrent(aAlert);
2. Port to android.
3. Start app.
What is the expected output? What do you see instead?
Expected is to see Alert. Console shows NullPointerException:
E/AndroidRuntime( 422): Uncaught handler: thread event-thread exiting due
to uncaught exception
E/AndroidRuntime( 422): java.lang.NullPointerException
E/AndroidRuntime( 422): at
org.microemu.android.device.ui.AndroidAlertUI.isToastable(AndroidAlertUI.java:118)
E/AndroidRuntime( 422): at
org.microemu.android.device.ui.AndroidAlertUI.showNotify(AndroidAlertUI.java:182)
E/AndroidRuntime( 422): at
javax.microedition.lcdui.Displayable.showNotify(Displayable.java:281)
E/AndroidRuntime( 422): at
javax.microedition.lcdui.Display$1.run(Display.java:543)
E/AndroidRuntime( 422): at
org.microemu.device.ui.EventDispatcher$RunnableEvent.run(EventDispatcher.java:246)
E/AndroidRuntime( 422): at
org.microemu.device.ui.EventDispatcher.post(EventDispatcher.java:164)
E/AndroidRuntime( 422): at
org.microemu.device.ui.EventDispatcher.run(EventDispatcher.java:99)
E/AndroidRuntime( 422): at java.lang.Thread.run(Thread.java:1060)
What version of the product are you using? On what operating system?
Irrelevant.
Please provide any additional information below.
displayableUnboxed.getType().equals(AlertType.INFO);
When Alert has no type, getType() returns null:
null.equals(AlertType.INFO) raises exception.
How to solve it:
--- D:\Old\tmp\AndroidAlertUI.java.old
+++ D:\Old\tmp\AndroidAlertUI.java.new
@@ -100,6 +100,9 @@
* {@link Alert#FOREVER}.
*/
protected boolean isToastable() {
+ if(displayableUnboxed.getType() == null) {
+ displayableUnboxed.setType(AlertType.INFO);
+ }
boolean isToastable = displayableUnboxed.getType().equals(
AlertType.INFO)
&& displayableUnboxed.getTimeout() != Alert.FOREVER
Attached file is patched
microemulator\microemu-android\src\org\microemu\android\device\ui\AndroidAlertUI.java
file.
Mar 17, 2010
Project Member
#1
bar...@gmail.com
Status:
Fixed
Apr 29, 2010
(No comment was entered for this change.)
Labels:
Milestone-3.0
|