Troubles with SurfaceView's surfaceCreated/Destroyed

by Dianne Hackborn » Wed, 01 Apr 2009 10:17:26 GMT


Sponsored Links
  don't think you've included enough code.  Where is this 'thread' variable
defined? Where do you clear it after finishing the thread?

I am also confused by the comment saying you "exiting" the activity in
rollDice -- you aren't calling finish, you are just starting another
activity, so the original activity is still there, and its window will just
be re-displayed when it is shown again.

The only thing I can think of is that you aren't handling the case where
your window is hidden and then shown again, causing surfaceCreated to be
called a second time on the same SurfaceView, but again there isn't enough
code here to really tell what is happening.

Also you do know that you can only call Thread.start() once on a particular
thread object, right?

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#start()

On Tue, Mar 31, 2009 at 6:46 PM, kbeal10 <kbea...@gmail.com> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support. All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. cocos2d for Android updated: Please help test on real phone.

I tested out the debug build from the site on my G1 phone running the
OTA Android 1.6 firmware:
http://cocos2d-android.googlecode.com/files/Cocos2D-debug.apk

AtlasSpriteTest, AtlasTest, ClickAndMoveTest, CocosNodeTest, MenuTest,
MotionStreakTest, SceneTest, SpritesTest showed white squares where I
would expect textures:
http://i.imgur.com/3w3En.png

Some of DrawPrimitivesTest works:
http://i.imgur.com/Es2H7.png

ParallaxTest crashed:
W/dalvikvm( 9532): threadid=3: thread exiting with uncaught exception
(group=0x4001da28)
E/AndroidRuntime( 9532): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 9532): java.lang.RuntimeException: Unable to start
activity ComponentInfo{org.cocos2d/org.cocos2d.tests.ParallaxTest}:
java.lang.NullPointerException
E/AndroidRuntime( 9532):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)
E/AndroidRuntime( 9532):        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2417)
E/AndroidRuntime( 9532):        at android.app.ActivityThread.access$2100
(ActivityThread.java:116)
E/AndroidRuntime( 9532):        at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1794)
E/AndroidRuntime( 9532):        at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime( 9532):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 9532):        at android.app.ActivityThread.main
(ActivityThread.java:4203)
E/AndroidRuntime( 9532):        at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime( 9532):        at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime( 9532):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 9532):        at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:549)
E/AndroidRuntime( 9532):        at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 9532): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 9532):        at org.cocos2d.nodes.CocosNode.addChild
(CocosNode.java:336)
E/AndroidRuntime( 9532):        at org.cocos2d.tests.ParallaxTest.onStart
(ParallaxTest.java:236)
E/AndroidRuntime( 9532):        at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:
1205)
E/AndroidRuntime( 9532):        at android.app.Activity.performStart
(Activity.java:3519)
E/AndroidRuntime( 9532):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2373)
E/AndroidRuntime( 9532):        ... 11 more
I/Process (   79): Sending signal. PID: 9532 SIG: 3

RotateWorldTest:
http://i.imgur.com/Nfkzv.png

SpritesTest and SceneTest wouldn't start about half the time I tried
them: "Sorry! Activity Cocos2D (in application Cocos2D) is not
responding." Log was this message repeated very many times:
W/SurfaceComposerClient( 9576): lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x420c40a0, state=00000043 (was 00000043)
W/SurfaceComposerClient( 9576): lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x420c40a0, state=00000043 (was 00000043)
W/SurfaceComposerClient( 9576): lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x420c40a0, state=00000043 (was 00000043)
W/SurfaceComposerClient( 9576): lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x420c40a0, state=00000043 (was 00000043)
W/SurfaceComposerClient( 9576): lock_layer timed out (is the CPU
pegged?) layer=1, lcblk=0x420c40a0, state=00000043 (was 00000043)

I was talking to someone who used cocos2d on the iPhone recently. It
sounded like he got a lot of great functionality without having to
implement it himself: particle systems, sprites with acceleration/
physics, plugins for facebook/twitter. It would be great to see it
make it to Android. Thanks for putting in the work so far.



> Philip

2. Box2d added to the Cocos2d for Android project

I would also like very much your suggestions on what you would like to
see happening with this project. I am currently doing all the work
without a device running in the emulator. Please test the code on your
phone and let me know if you run into any problems.

Thanks!

LdS

-- 

3. Box2d added to the Cocos2d for Android project

4. android-porting on HTC S740

5. iPad

6. Problem in using android-vnc-viewer

7. Opening a gzipped raw resource file