Skip to main content

Android port and Maps

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
azlist1
Offline
Joined: 2008-05-20

Hi all !!

I was just wondering if anyone had managed to create a Google Maps component
for the Android port of LWUIT ?

And if not what would be the best way to implement this, where should I
start looking ?

Any ideas , suggestions welcome.

Cheers,

Alex

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
thorsten_s
Offline
Joined: 2008-08-15

You could try it with the relatively new com.sun.lwuit.PeerComponent, wrapping it around an Android Map component (is there one? I never checked, but I assume there is).

<br />
com.sun.lwuit.PeerComponent p = com.sun.lwuit.PeerComponent.create(myNativeMap);<br />

I recently added support for this to the implementation for Android, but only tested it for a few buttons. It should work for any Android View, though. Work with the native component on the Android UI thread and with the LWUIT Peer on the EDT.

klemensz
Offline
Joined: 2007-02-25

Hi,
I tried this:

        android.widget.Button btn = new android.widget.Button(LWUITActivity.currentActivity);
        btn.setText(&quot;Test&quot;);
        PeerComponent peer = PeerComponent.create(btn);
        cContent.addComponent(peer);

But it always gives me an exception:
03-30 17:48:09.773: ERROR/AndroidRuntime(544): FATAL EXCEPTION: main
03-30 17:48:09.773: ERROR/AndroidRuntime(544): java.lang.NullPointerException
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at com.sun.lwuit.impl.android.AndroidImplementation$AndroidPeer.blockNativeFocus(AndroidImplementation.java:1414)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at com.sun.lwuit.impl.android.AndroidImplementation$AndroidPeer$6.run(AndroidImplementation.java:1450)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at android.os.Handler.handleCallback(Handler.java:587)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at android.os.Looper.loop(Looper.java:123)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at java.lang.reflect.Method.invoke(Method.java:521)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-30 17:48:09.773: ERROR/AndroidRuntime(544): at dalvik.system.NativeStart.main(Native Method)
Am I missing something?

thorsten_s
Offline
Joined: 2008-08-15

I would guess this is a threading problem. The Android component usually requires to be created on the Android UI thread while the same holds true for LWUIT components on the EDT. If the sample code you posted is running on the Android UI thread you should serialize the the PeerComponent stuff (the last two lines) with the LWUIT EDT.