gcfavorites / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

[android] Alert without a type exits application #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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:11
8)
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:24
6)
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.

Original issue reported on code.google.com by Kot.Zgu...@gmail.com on 3 Mar 2010 at 3:19

Attachments:

GoogleCodeExporter commented 8 years ago
Has been fixed in a more generic way (not modifying displayableUnboxed null 
type)

Original comment by bar...@gmail.com on 17 Mar 2010 at 12:43

GoogleCodeExporter commented 8 years ago

Original comment by bar...@gmail.com on 29 Apr 2010 at 10:37