[android-developers] Android 2.3 Causes memory intensive app to crash

2011-03-03 Thread TjerkW
Hello all,

I created an app which loads heavy 3d models into memory. This app
runs fine on pre android 2.3 devices.

However i updated my nexus one to Android 2.3, and now the app
crashes. I get the error listed below.
However this error is not really usefull. What should i do to fix
this?
Using less memory is difficult because i still need to load the 3d
model into memory.


03-03 23:18:35.483: INFO/Min3D(17779): Renderer.onSurfaceCreated()
03-03 23:18:35.483: VERBOSE/Min3D(17779): RenderCaps - openGLVersion:
1.1
03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps -
maxTextureUnits: 2
03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps - maxTextureSize:
4096
03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps - maxLights: 8
03-03 23:18:35.503: INFO/Min3D(17779): Scene.init()
03-03 23:18:35.503: VERBOSE/x(17779): ManagedLightList.reset()
03-03 23:18:35.503: DEBUG/WeaponDescripitonActivity(17779): initScene
03-03 23:18:35.503: INFO/Min3D(17779): Renderer.onSurfaceChanged()
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): /dev/pmem: no more pmem
available
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): couldn't open pmem
(Unknown error: 0)
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): gralloc failed err=Out of
memory
03-03 23:18:35.543: WARN/GraphicBufferAllocator(96): alloc(800, 480,
1, 0303, ...) failed -12 (Out of memory)
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96): Allocated
buffers:
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3309b0:
1243.75 KiB |  800 ( 800) x  398 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x351288:
544.00 KiB |  520 ( 544) x  256 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3c6a70:
1500.00 KiB |  800 ( 800) x  480 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3ef848:
1500.00 KiB |  800 ( 800) x  480 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3f63a0:
1243.75 KiB |  800 ( 800) x  398 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x40f358:
723.75 KiB |  480 ( 480) x  386 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x435788:
750.00 KiB |  480 ( 480) x  800 |4 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x47d640:
723.75 KiB |  480 ( 480) x  386 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4abf38:
1018.75 KiB |  800 ( 800) x  326 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4afd50:
1500.00 KiB |  480 ( 480) x  800 |2 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4bd290:
118.75 KiB |  800 ( 800) x   38 |2 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4d6cf0:
486.00 KiB |  375 ( 384) x  324 |1 | 0x0303
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4e0060:
1500.00 KiB |  480 ( 480) x  800 |2 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x504da0:
448.00 KiB |  432 ( 448) x  256 |1 | 0x0133
03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x506738:
1428.75 KiB |  480 ( 480)
03-03 23:18:35.543: ERROR/SurfaceFlinger(96):
Layer::requestBuffer(this=0x63d530), index=1, w=800, h=480 failed (Out
of memory)
03-03 23:18:35.543: ERROR/Surface(17779): Surface (identity=2407)
requestBuffer(1, 0, 0, 1, 0203) returned a buffer with a null
handle
03-03 23:18:35.543: ERROR/Surface(17779): getBufferLocked(1, 0, 0, 1,
0203) failed (Out of memory)
03-03 23:18:35.543: ERROR/Adreno200-EGL(17779): egliSwapWindowSurface:
unable to dequeue native buffer
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): /dev/pmem: no more pmem
available
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): couldn't open pmem (No
such file or directory)
03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): gralloc failed err=Out of
memory

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android 2.3 Causes memory intensive app to crash

2011-03-03 Thread TjerkW
:99)
03-04 00:05:43.448: ERROR/ViewRoot(96): at
android.os.Looper.loop(Looper.java:123)
03-04 00:05:43.448: ERROR/ViewRoot(96): at
com.android.server.WindowManagerService
$PolicyThread.run(WindowManagerService.java:595)
03-04 00:05:43.498: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 293K, 52%
free 3231K/6599K, external 7598K/9488K, paused 84ms
03-04 00:05:43.558: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 30K, 52%
free 3200K/6599K, external 7426K/9273K, paused 56ms
03-04 00:05:43.598: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 25K, 52%
free 3175K/6599K, external 7244K/9047K, paused 32ms
03-04 00:05:43.638: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 9K, 52%
free 3168K/6599K, external 7244K/9047K, paused 31ms
03-04 00:05:43.968: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 176K, 50%
free 3352K/6599K, external 8674K/9047K, paused 36ms
03-04 00:05:44.118: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 89K, 48%
free 3454K/6599K, external 8529K/9047K, paused 33ms
03-04 00:05:44.168: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 9K, 48%
free 3465K/6599K, external 8529K/9047K, paused 33ms
03-04 00:05:44.228: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 20K, 48%
free 3481K/6599K, external 8639K/9047K, paused 36ms
03-04 00:05:44.228: WARN/AppWidgetHostView(17337): can't inflate
defaultView because mInfo is missing
03-04 00:05:44.268: DEBUG/dalvikvm(17337): GC_EXPLICIT freed 1K, 48%
free 3483K/6599K, external 8639K/9047K, paused 34ms
03-04 00:05:44.328: DEBUG/dalvikvm(17337): GC_EXTERNAL_ALLOC freed 8K,
48% free 3495K/6599K, external 9030K/9047K, paused 33ms


On Mar 3, 11:24 pm, Dianne Hackborn hack...@android.com wrote:
 The error isn't main memory, it is surface memory.  There are a *ton* of
 full-screen surfaces currently created.  You can use adb shell dumpsys
 window and adb shell dumpsys SurfaceFlinger to see more information about
 which windows these go with.









 On Thu, Mar 3, 2011 at 2:21 PM, TjerkW tje...@gmail.com wrote:
  Hello all,

  I created an app which loads heavy 3d models into memory. This app
  runs fine on pre android 2.3 devices.

  However i updated my nexus one to Android 2.3, and now the app
  crashes. I get the error listed below.
  However this error is not really usefull. What should i do to fix
  this?
  Using less memory is difficult because i still need to load the 3d
  model into memory.

  03-03 23:18:35.483: INFO/Min3D(17779): Renderer.onSurfaceCreated()
  03-03 23:18:35.483: VERBOSE/Min3D(17779): RenderCaps - openGLVersion:
  1.1
  03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps -
  maxTextureUnits: 2
  03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps - maxTextureSize:
  4096
  03-03 23:18:35.503: VERBOSE/Min3D(17779): RenderCaps - maxLights: 8
  03-03 23:18:35.503: INFO/Min3D(17779): Scene.init()
  03-03 23:18:35.503: VERBOSE/x(17779): ManagedLightList.reset()
  03-03 23:18:35.503: DEBUG/WeaponDescripitonActivity(17779): initScene
  03-03 23:18:35.503: INFO/Min3D(17779): Renderer.onSurfaceChanged()
  03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): /dev/pmem: no more pmem
  available
  03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): couldn't open pmem
  (Unknown error: 0)
  03-03 23:18:35.543: ERROR/qsd8k.gralloc(96): gralloc failed err=Out of
  memory
  03-03 23:18:35.543: WARN/GraphicBufferAllocator(96): alloc(800, 480,
  1, 0303, ...) failed -12 (Out of memory)
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96): Allocated
  buffers:
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3309b0:
  1243.75 KiB |  800 ( 800) x  398 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x351288:
  544.00 KiB |  520 ( 544) x  256 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3c6a70:
  1500.00 KiB |  800 ( 800) x  480 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3ef848:
  1500.00 KiB |  800 ( 800) x  480 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x3f63a0:
  1243.75 KiB |  800 ( 800) x  398 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x40f358:
  723.75 KiB |  480 ( 480) x  386 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x435788:
  750.00 KiB |  480 ( 480) x  800 |        4 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x47d640:
  723.75 KiB |  480 ( 480) x  386 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4abf38:
  1018.75 KiB |  800 ( 800) x  326 |        1 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4afd50:
  1500.00 KiB |  480 ( 480) x  800 |        2 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4bd290:
  118.75 KiB |  800 ( 800) x   38 |        2 | 0x0133
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96):   0x4d6cf0:
  486.00 KiB |  375 ( 384) x  324 |        1 | 0x0303
  03-03 23:18:35.543: DEBUG/GraphicBufferAllocator(96

[android-developers] Re: Did the Honeycomb platform package go away?

2011-01-31 Thread TjerkW
@davemac could you share your copy somehow? A lot of people cannot
test against honeycomb now.

On Jan 30, 1:07 am, davemac davemac...@gmail.com wrote:
 I was able to get a copy of the file from a friend of mine so I'm now
 good. The repository.xml file on Google has this for the sha1
 checksum:

 sdk:archive os=any arch=any
 sdk:size99663071/sdk:size
 sdk:checksum type=sha1b11da2f078b7383b0c3357847ab6ede367973ce3/
 sdk:checksum
 sdk:urlandroid-3.0_pre_r01-linux.zip/sdk:url
 /sdk:archive

 so if you can find another copy and the checksum matches you should be
 fine. Note: you don't really need to use the SDK Manager to install
 it. Just unzip it and stick the android-Honeycomb folder underneath
 platforms.

 - dave

 On Jan 29, 6:57 pm, henrik henrik.aron...@gmail.com wrote:







  On Jan 29, 9:03 pm, circle kenne...@gmail.com wrote:

   Same. It seems that Google removed the file.

   I found some links on the web, but don't feel very comfortable installing
   from unofficial source...

  By some links I guess you 
  meanhttp://burnbit.com/torrent/162617/android_3_0_pre_r01_linux_zip.
  It's useless, since no-one is seeding.

  H

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Did the Honeycomb platform package go away?

2011-01-29 Thread TjerkW
Also gone for me somebody removed it by accident?

On Jan 29, 9:03 pm, circle kenne...@gmail.com wrote:
 Same. It seems that Google removed the file.

 I found some links on the web, but don't feel very comfortable installing
 from unofficial source...

 What's up, Google?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Widget with two Textview like Twitter Widget: Wrap

2010-08-04 Thread TjerkW
I basically want a widget which has a simlar layout as the twitter
widget like this

[AUTHOR] [TWEET text bla bla
bla balb albalbalbal bla bla]

As you can see the tweet text nicely wraps around the AUTHOR element.
This can be done with one TextView using the following method:
http://developer.android.com/guide/appendix/faq/commontasks.html#selectingtext

The problem is that its a widget and i only have access to the ui
elements using the RemoteViews:
http://developer.android.com/reference/android/widget/RemoteViews.html

I was thinking of using a layout manager for this, but its impossible
because textviews are always rectangular.

So how do i do this?
I know you helped twitter build their application. So it would be nice
if you could help us.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Widget with two Textview like Twitter Widget: Wrap

2010-08-04 Thread TjerkW
I forgot to mention it.. but the point is of course that i want tot
style the Author field differently that the other field.
Else string concatenation would be the -duh- solution.

However styling it through the RemoteViews is not possible.
So how did twitter do this?

On Aug 4, 4:03 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Aug 4, 2010 at 9:58 AM, TjerkW tje...@gmail.com wrote:
  I basically want a widget which has a simlar layout as the twitter
  widget like this

  [AUTHOR] [TWEET text bla bla
  bla balb albalbalbal bla bla]

  As you can see the tweet text nicely wraps around the AUTHOR element.
  This can be done with one TextView using the following method:
 http://developer.android.com/guide/appendix/faq/commontasks.html#sele...

  The problem is that its a widget and i only have access to the ui
  elements using the RemoteViews:
 http://developer.android.com/reference/android/widget/RemoteViews.html

  I was thinking of using a layout manager for this, but its impossible
  because textviews are always rectangular.

  So how do i do this?

 Step #1: Use string concatenation to put the author and tweet in a
 single String (or SpannedString created from Html.fromHtml(), or
 whatever).

 Step #2: Call setTextViewText() on your RemoteViews

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Widget with two Textview like Twitter Widget: Wrap

2010-08-04 Thread TjerkW
AAAh cool didnt now about Spanned extends CharSequence... Cool!

On Aug 4, 4:03 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Aug 4, 2010 at 9:58 AM, TjerkW tje...@gmail.com wrote:
  I basically want a widget which has a simlar layout as the twitter
  widget like this

  [AUTHOR] [TWEET text bla bla
  bla balb albalbalbal bla bla]

  As you can see the tweet text nicely wraps around the AUTHOR element.
  This can be done with one TextView using the following method:
 http://developer.android.com/guide/appendix/faq/commontasks.html#sele...

  The problem is that its a widget and i only have access to the ui
  elements using the RemoteViews:
 http://developer.android.com/reference/android/widget/RemoteViews.html

  I was thinking of using a layout manager for this, but its impossible
  because textviews are always rectangular.

  So how do i do this?

 Step #1: Use string concatenation to put the author and tweet in a
 single String (or SpannedString created from Html.fromHtml(), or
 whatever).

 Step #2: Call setTextViewText() on your RemoteViews

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Basically i have an AppWidgetProvider which starts a Service on
update. That service starts a thread and at the end it updates the
widget by calling AppWidgetManager.updateAppWidget.

But i get a NullPointerException? What am i doing wrong? The Service
is not in a different process..


07-14 10:30:29.936: INFO/HyvesWidgetProvider(12077): updateAppWidget
appWidgetId=63
07-14 10:30:35.156: DEBUG/dalvikvm(12077): threadid=14: still
suspended after undo (sc=1 dc=1 s=Y)
07-14 10:30:35.156: DEBUG/dalvikvm(12077): GC_EXPLICIT freed 4078
objects / 373584 bytes in 97ms
07-14 10:30:36.711: WARN/dalvikvm(12077): threadid=14: thread exiting
with uncaught exception (group=0x4001d7f0)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): FATAL EXCEPTION:
Thread-16
07-14 10:30:36.796: ERROR/AndroidRuntime(12077):
java.lang.NullPointerException
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
android.widget.RemoteViews
$ReflectionAction.writeToParcel(RemoteViews.java:399)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.android.internal.appwidget.IAppWidgetService$Stub
$Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
246)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
265)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetProvider.java:
75)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.onUserInfoRetrieved(HyvesWidgetService.java:
162)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.access
$2(HyvesWidgetService.java:149)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService
$2.onItemRetrieved(HyvesWidgetService.java:123)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService
$2.onItemRetrieved(HyvesWidgetService.java:1)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.proxy.content.CachePolicyImpl.getItemById(CachePolicyImpl.java:
33)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.proxy.content.BaseSourcesInfo.getItemById(BaseSourcesInfo.java:
90)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.onBuzzItemRetrieved(HyvesWidgetService.java:
120)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.access
$0(HyvesWidgetService.java:118)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService
$1.onItemRetrieved(HyvesWidgetService.java:96)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService
$1.onItemRetrieved(HyvesWidgetService.java:1)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.proxy.content.CachePolicyImpl.getItemByParentIdAndPosition(CachePolicyImpl.java:
68)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.proxy.content.BaseSourcesInfo.getItemByParentIdAndPosition(BaseSourcesInfo.java:
98)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.onUpdate(HyvesWidgetService.java:
89)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
com.hyves.android.widget.HyvesWidgetService.run(HyvesWidgetService.java:
83)
07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at
java.lang.Thread.run(Thread.java:1096)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Well it worked if i just did it from the AppWidgetProvider.onUpdate.
And this service i wrote uses the same approach as Jeff Sharkey
(Android Team Developer)
uses in his example Widget:

http://code.google.com/p/android-sky/source/browse/trunk/Sky/src/org/jsharkey/sky/UpdateService.java

So what am i doing wrong? Should i still submit it to a handler?
Can you explain me how todo that?

On Jul 14, 10:44 am, Kostya Vasilyev kmans...@gmail.com wrote:
 Are you calling updateAppWidget from the worker thread?

 If so, don't. UI calls can only be made from the UI thread.

 Use a Handler / Runnable to post data calculated by the worker thread to
 the UI thread and call updateAppWidget from there.

 -- Kostya

 14.07.2010 12:37, TjerkW пишет:





  Basically i have an AppWidgetProvider which starts a Service on
  update. That service starts a thread and at the end it updates the
  widget by calling AppWidgetManager.updateAppWidget.

  But i get a NullPointerException? What am i doing wrong? The Service
  is not in a different process..

  07-14 10:30:29.936: INFO/HyvesWidgetProvider(12077): updateAppWidget
  appWidgetId=63
  07-14 10:30:35.156: DEBUG/dalvikvm(12077): threadid=14: still
  suspended after undo (sc=1 dc=1 s=Y)
  07-14 10:30:35.156: DEBUG/dalvikvm(12077): GC_EXPLICIT freed 4078
  objects / 373584 bytes in 97ms
  07-14 10:30:36.711: WARN/dalvikvm(12077): threadid=14: thread exiting
  with uncaught exception (group=0x4001d7f0)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077): FATAL EXCEPTION:
  Thread-16
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):
  java.lang.NullPointerException
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.widget.RemoteViews
  $ReflectionAction.writeToParcel(RemoteViews.java:399)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.android.internal.appwidget.IAppWidgetService$Stub
  $Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
  246)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
  265)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetPro 
  vider.java:
  75)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onUserInfoRetrieved(HyvesWidget 
  Service.java:
  162)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.access
  $2(HyvesWidgetService.java:149)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $2.onItemRetrieved(HyvesWidgetService.java:123)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $2.onItemRetrieved(HyvesWidgetService.java:1)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.CachePolicyImpl.getItemById(CachePolicyImpl 
  .java:
  33)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.BaseSourcesInfo.getItemById(BaseSourcesInfo 
  .java:
  90)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onBuzzItemRetrieved(HyvesWidget 
  Service.java:
  120)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.access
  $0(HyvesWidgetService.java:118)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $1.onItemRetrieved(HyvesWidgetService.java:96)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $1.onItemRetrieved(HyvesWidgetService.java:1)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.CachePolicyImpl.getItemByParentIdAndPositio 
  n(CachePolicyImpl.java:
  68)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.BaseSourcesInfo.getItemByParentIdAndPositio 
  n(BaseSourcesInfo.java:
  98)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onUpdate(HyvesWidgetService.jav 
  a:
  89)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.run(HyvesWidgetService.java:
  83)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  java.lang.Thread.run(Thread.java:1096)

 --
 Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
B.t.w it worked fine on the Emulator intially (no widget where loaded
previously)

On Jul 14, 10:44 am, Kostya Vasilyev kmans...@gmail.com wrote:
 Are you calling updateAppWidget from the worker thread?

 If so, don't. UI calls can only be made from the UI thread.

 Use a Handler / Runnable to post data calculated by the worker thread to
 the UI thread and call updateAppWidget from there.

 -- Kostya

 14.07.2010 12:37, TjerkW пишет:





  Basically i have an AppWidgetProvider which starts a Service on
  update. That service starts a thread and at the end it updates the
  widget by calling AppWidgetManager.updateAppWidget.

  But i get a NullPointerException? What am i doing wrong? The Service
  is not in a different process..

  07-14 10:30:29.936: INFO/HyvesWidgetProvider(12077): updateAppWidget
  appWidgetId=63
  07-14 10:30:35.156: DEBUG/dalvikvm(12077): threadid=14: still
  suspended after undo (sc=1 dc=1 s=Y)
  07-14 10:30:35.156: DEBUG/dalvikvm(12077): GC_EXPLICIT freed 4078
  objects / 373584 bytes in 97ms
  07-14 10:30:36.711: WARN/dalvikvm(12077): threadid=14: thread exiting
  with uncaught exception (group=0x4001d7f0)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077): FATAL EXCEPTION:
  Thread-16
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):
  java.lang.NullPointerException
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.widget.RemoteViews
  $ReflectionAction.writeToParcel(RemoteViews.java:399)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.android.internal.appwidget.IAppWidgetService$Stub
  $Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
  246)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
  265)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetPro 
  vider.java:
  75)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onUserInfoRetrieved(HyvesWidget 
  Service.java:
  162)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.access
  $2(HyvesWidgetService.java:149)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $2.onItemRetrieved(HyvesWidgetService.java:123)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $2.onItemRetrieved(HyvesWidgetService.java:1)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.CachePolicyImpl.getItemById(CachePolicyImpl 
  .java:
  33)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.BaseSourcesInfo.getItemById(BaseSourcesInfo 
  .java:
  90)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onBuzzItemRetrieved(HyvesWidget 
  Service.java:
  120)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.access
  $0(HyvesWidgetService.java:118)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $1.onItemRetrieved(HyvesWidgetService.java:96)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService
  $1.onItemRetrieved(HyvesWidgetService.java:1)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.CachePolicyImpl.getItemByParentIdAndPositio 
  n(CachePolicyImpl.java:
  68)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.proxy.content.BaseSourcesInfo.getItemByParentIdAndPositio 
  n(BaseSourcesInfo.java:
  98)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.onUpdate(HyvesWidgetService.jav 
  a:
  89)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  com.hyves.android.widget.HyvesWidgetService.run(HyvesWidgetService.java:
  83)
  07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
  java.lang.Thread.run(Thread.java:1096)

 --
 Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
/ActivityManager(59):   d.process.media: 0% =
0% user + 0% kernel / faults: 126 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   s:FriendService: 0% =
0% user + 0% kernel / faults: 133 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   m.android.music: 0% =
0% user + 0% kernel / faults: 122 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):  -zygote: 0% = 0% user
+ 0% kernel


Here is my code in the AppWidgetProvider class:


@Override
public void onUpdate(Context context, AppWidgetManager manager,
int[] appWidgetIds) {
log(onUpdate);
// If no specific widgets requested, collect list of all
if (appWidgetIds == null) {
appWidgetIds = manager.getAppWidgetIds(
new ComponentName(context,
HyvesWidgetProvider.class));
}

// Request update for these widgets and launch updater service
HyvesWidgetService.requestUpdate(appWidgetIds);
context.startService(new Intent(context,
HyvesWidgetService.class));
}

And code from the IntentService


/**
 * Start this service, creating a background processing thread, if
not
 * already running. If started with {...@link #ACTION_UPDATE_ALL},
will
 * automatically add all widgets to the requested update queue.
 */
@Override
protected void onHandleIntent(Intent intent) {
// If requested, trigger update of all widgets
if (ACTION_UPDATE_ALL.equals(intent.getAction())) {

AppWidgetManager manager =
AppWidgetManager.getInstance(this);
Log.d(TAG, Requested UPDATE_ALL action);
requestUpdate(manager.getAppWidgetIds(new
ComponentName(this, HyvesWidgetProvider.class)));
}

onUpdate();
}


onUpdate calls an asynchronous api call, and a callback updates tthe
widget.


On Jul 14, 12:58 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jul 14, 2010 at 4:37 AM, TjerkW tje...@gmail.com wrote:
  Basically i have an AppWidgetProvider which starts a Service on
  update. That service starts a thread and at the end it updates the
  widget by calling AppWidgetManager.updateAppWidget.

 Turn the Service into an IntentService, and get rid of your own
 thread. IntentService gives you your work on a background thread
 automatically. See:

 http://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/Micr...

  But i get a NullPointerException? What am i doing wrong? The Service
  is not in a different process..

 That is impossible to say without seeing your code.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Request update is a very fast method

   /**
 * Request updates for the given widgets. Will only queue them up,
you are
 * still responsible for starting a processing thread if needed,
usually by
 * starting the parent service.
 */
public static void requestUpdate(int[] appWidgetIds) {
synchronized (lock) {
for (int appWidgetId : appWidgetIds) {
HyvesWidgetService.appWidgetIds.add(appWidgetId);
}
}
}


Yeah the onUpdate (may) fork antother thread.
I now solved it by waiting in the IntentService thread on an object
using a lock:

lock.wait();

and then if it is done i call lock.notify().

This should work i think... i'm trying it out right now.

On Jul 14, 2:00 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jul 14, 2010 at 7:44 AM, TjerkW tje...@gmail.com wrote:
  07-14 13:38:49.503: WARN/ActivityManager(59): Timeout of broadcast
  BroadcastRecord{43f724c0 android.appwidget.action.APPWIDGET_ENABLED} -
  receiver=android.os.binderpr...@43deed00
  07-14 13:38:49.513: WARN/ActivityManager(59): Receiver during timeout:
  ResolveInfo{43f72438 com.hyves.android.widget.HyvesWidgetProvider p=0
  o=0 m=0x0}
    �...@override
     public void onUpdate(Context context, AppWidgetManager manager,
  int[] appWidgetIds) {
         log(onUpdate);
         // If no specific widgets requested, collect list of all
         if (appWidgetIds == null) {
             appWidgetIds = manager.getAppWidgetIds(
                     new ComponentName(context,
  HyvesWidgetProvider.class));
         }

         // Request update for these widgets and launch updater service
         HyvesWidgetService.requestUpdate(appWidgetIds);
         context.startService(new Intent(context,
  HyvesWidgetService.class));
     }

 I have no idea what:

 HyvesWidgetService.requestUpdate(appWidgetIds);

 does, but that would seem to be taking too long.







  And code from the IntentService

     /**
      * Start this service, creating a background processing thread, if
  not
      * already running. If started with {...@link #ACTION_UPDATE_ALL},
  will
      * automatically add all widgets to the requested update queue.
      */
    �...@override
     protected void onHandleIntent(Intent intent) {
         // If requested, trigger update of all widgets
         if (ACTION_UPDATE_ALL.equals(intent.getAction())) {

             AppWidgetManager manager =
  AppWidgetManager.getInstance(this);
             Log.d(TAG, Requested UPDATE_ALL action);
             requestUpdate(manager.getAppWidgetIds(new
  ComponentName(this, HyvesWidgetProvider.class)));
         }

         onUpdate();
     }

  onUpdate calls an asynchronous api call, and a callback updates tthe
  widget.

 Wait, whoa, what? You are already in a background thread. Is
 onUpdate() forking yet another thread?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Works on the emulator.. but on my nexus one i still get the nasty
nullpointerexception deep inside the Android apis


07-14 14:33:53.105: ERROR/HyvesWidgetService(13806): Failed updating
widget: 68, due to java.lang.NullPointerException
07-14 14:33:53.105: WARN/System.err(13806):
java.lang.NullPointerException
07-14 14:33:53.115: WARN/System.err(13806): at
android.widget.RemoteViews
$ReflectionAction.writeToParcel(RemoteViews.java:399)
07-14 14:33:53.115: WARN/System.err(13806): at
android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
07-14 14:33:53.115: WARN/System.err(13806): at
com.android.internal.appwidget.IAppWidgetService$Stub
$Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
07-14 14:33:53.125: WARN/System.err(13806): at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
246)
07-14 14:33:53.125: WARN/System.err(13806): at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
265)
07-14 14:33:53.125: WARN/System.err(13806): at
com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetProvider.java:
75)
07-14 14:33:53.135: WARN/System.err(13806): at
com.hyves.android.widget.HyvesWidgetService.onHandleIntent(HyvesWidgetService.java:
115)
07-14 14:33:53.135: WARN/System.err(13806): at
android.app.IntentService
$ServiceHandler.handleMessage(IntentService.java:59)
07-14 14:33:53.145: WARN/System.err(13806): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-14 14:33:53.145: WARN/System.err(13806): at
android.os.Looper.loop(Looper.java:123)


On Jul 14, 2:00 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jul 14, 2010 at 7:44 AM, TjerkW tje...@gmail.com wrote:
  07-14 13:38:49.503: WARN/ActivityManager(59): Timeout of broadcast
  BroadcastRecord{43f724c0 android.appwidget.action.APPWIDGET_ENABLED} -
  receiver=android.os.binderpr...@43deed00
  07-14 13:38:49.513: WARN/ActivityManager(59): Receiver during timeout:
  ResolveInfo{43f72438 com.hyves.android.widget.HyvesWidgetProvider p=0
  o=0 m=0x0}
    �...@override
     public void onUpdate(Context context, AppWidgetManager manager,
  int[] appWidgetIds) {
         log(onUpdate);
         // If no specific widgets requested, collect list of all
         if (appWidgetIds == null) {
             appWidgetIds = manager.getAppWidgetIds(
                     new ComponentName(context,
  HyvesWidgetProvider.class));
         }

         // Request update for these widgets and launch updater service
         HyvesWidgetService.requestUpdate(appWidgetIds);
         context.startService(new Intent(context,
  HyvesWidgetService.class));
     }

 I have no idea what:

 HyvesWidgetService.requestUpdate(appWidgetIds);

 does, but that would seem to be taking too long.







  And code from the IntentService

     /**
      * Start this service, creating a background processing thread, if
  not
      * already running. If started with {...@link #ACTION_UPDATE_ALL},
  will
      * automatically add all widgets to the requested update queue.
      */
    �...@override
     protected void onHandleIntent(Intent intent) {
         // If requested, trigger update of all widgets
         if (ACTION_UPDATE_ALL.equals(intent.getAction())) {

             AppWidgetManager manager =
  AppWidgetManager.getInstance(this);
             Log.d(TAG, Requested UPDATE_ALL action);
             requestUpdate(manager.getAppWidgetIds(new
  ComponentName(this, HyvesWidgetProvider.class)));
         }

         onUpdate();
     }

  onUpdate calls an asynchronous api call, and a callback updates tthe
  widget.

 Wait, whoa, what? You are already in a background thread. Is
 onUpdate() forking yet another thread?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Okay i have that now and i still get the nullpointerexception on an
Nexus One.

I still use a separate thread because the client libray i use does a
asyncrhonous api call.
But i syncrhonize it by an object lock.

So it should work fine.. but it doesnt.

On Jul 14, 2:50 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jul 14, 2010 at 8:35 AM, TjerkW tje...@gmail.com wrote:
  Works on the emulator.. but on my nexus one i still get the nasty
  nullpointerexception deep inside the Android apis

 At this point, I am fairly lost with your code. I don't know why you
 need onUpdate() to fork a thread. Make sure that you keep your code
 that gets the AppWidgetManager, creates/populates the RemoteViews, and
 calls updateAppWidget() all in a contiguous block of code, called on
 one thread, and it should work fine (barring supplying null values to
 methods on RemoteViews or something).

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Im calling it from the IntentService onHandleIntent method which
should run in its own worker thread as the apidocs explain.

It works on the emulator.
However on the Nexus One i get the nullpointer exception on calling
manager.updateAppWidget ...
See the stacktrace in a previous post.

On Jul 14, 3:12 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jul 14, 2010 at 9:01 AM, Kostya Vasilyev kmans...@gmail.com wrote:
  From what thread are you ultimately calling

  AppWidgetManager.updateAppWidget

  ?

  It has to be the UI thread, I think you should check to make sure.

 No, it doesn't. I have a few examples where updating the app widget
 from any thread is fine, such as the one I linked to earlier:

 http://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/Micr...

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Hmm yeah,.. im trying to make a simple widget now and adding more
stuff.

However maybe this output from LogCat also helps:


07-14 15:57:58.845: ERROR/ActivityManager(59): ANR in
com.hyves.android.application
07-14 15:57:58.845: ERROR/ActivityManager(59): Reason: Broadcast of
Intent { act=android.appwidget.action.APPWIDGET_UPDATE
cmp=com.hyves.android.application/
com.hyves.android.widget.HyvesWidgetProvider (has extras) }
07-14 15:57:58.845: ERROR/ActivityManager(59): Load: 2.37 / 0.97 /
0.49
07-14 15:57:58.845: ERROR/ActivityManager(59): CPU usage from 476365ms
to 80ms ago:
07-14 15:57:58.845: ERROR/ActivityManager(59):   system_server: 4% =
3% user + 0% kernel / faults: 14885 minor 282 major


On Jul 14, 3:27 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 Mark,

 AFAIK, all UI methods are supposed to be called from the UI thread, are
 widget calls an exception to this rule?

 -- Kostya

 14.07.2010 17:12, Mark Murphy пишет:





  On Wed, Jul 14, 2010 at 9:01 AM, Kostya Vasilyevkmans...@gmail.com  wrote:

   From what thread are you ultimately calling

  AppWidgetManager.updateAppWidget

  ?

  It has to be the UI thread, I think you should check to make sure.

  No, it doesn't. I have a few examples where updating the app widget
  from any thread is fine, such as the one I linked to earlier:

 http://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/Micr...

 --
 Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Thanks... it was not a threading issue... i was calling

 views.setImageViewBitmap(R.id.profile_image, icon);

with a null icon Most stupid mistake ever.
But i think it would be better if android throws a better exception
with a clear message.

Anyways... solved!
And a lot learned today!

Thanks to you all!

On Jul 14, 4:46 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 ... which is in turn caused by a crash:

 07-14 10:30:36.796: ERROR/AndroidRuntime(12077): FATAL EXCEPTION:
 Thread-16
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):
 java.lang.NullPointerException
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 android.widget.RemoteViews
 $ReflectionAction.writeToParcel(RemoteViews.java:399)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 com.android.internal.appwidget.IAppWidgetService$Stub
 $Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
 246)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
 265)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetPro 
 vider.java:
 75)

 That is, updateAppWidget starts writing the RemoteViews object into a
 Parcel, and crashes. Obviously the onUpdate() never returns, thus the ANR.

 This runs on a separate thread, as can be seen further in the stack trace:

 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 com.hyves.android.widget.HyvesWidgetService.run(HyvesWidgetService.java:
 83)
 07-14 10:30:36.796: ERROR/AndroidRuntime(12077):     at
 java.lang.Thread.run(Thread.java:1096)

 Either it's really a threading problem, or else some data related to
 RemoteViews is null (such as updateViews.setTextViewText(R.id.xxx,
 null), or even the RemoteViews object itself is null). The latter one
 should be easy to check by stepping through in the debugger.

 -- Kostya

 14.07.2010 18:28, Tjerk Gmail пишет:





  Aaah cool i didnt think of that problem!
  On Jul 14, 2010, at 4:15 PM, Mark Murphy wrote:

  On Wed, Jul 14, 2010 at 10:00 AM, TjerkWtje...@gmail.com  wrote:

  Hmm yeah,.. im trying to make a simple widget now and adding more
  stuff.

  However maybe this output from LogCat also helps:

  07-14 15:57:58.845: ERROR/ActivityManager(59): ANR in
  com.hyves.android.application
  07-14 15:57:58.845: ERROR/ActivityManager(59): Reason: Broadcast of
  Intent { act=android.appwidget.action.APPWIDGET_UPDATE
  cmp=com.hyves.android.application/
  com.hyves.android.widget.HyvesWidgetProvider (has extras) }

  This should only happen if onUpdate() of your AppWidgetProvider is
  taking too long. This may be tied to some of the funky thread locking
  you're trying to do.

  --
  Mark Murphy (a Commons Guy)
 http://commonsware.com|http://github.com/commonsguy
 http://commonsware.com/blog|http://twitter.com/commonsguy

  _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
  Available!

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  Tjerk Wolterink
  T +31645300385
  tje...@gmail.com
 http://twitter.com/tjerkw
 http://tjerkwolterink.hyves.nl

 --
 Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Garbage Collection Infinit Loop: clamp GC FOR MALLOC Grow heap loop

2010-07-08 Thread TjerkW

I am still not 100% sure what caused it but i solved it as follows.

I created a Service with a Handler. However that Handler was not in
its own thread.
So i had someting like:

public class ImageUploadService extends IntentService {
  private Handler handler = new Handler()


The service was not run in its own process. This caused the handler to
be executed in the ui thread.

The solution was to wrap the handler in a thread like this:

class UploadLooperThread extends Thread {
public Handler mHandler;

public void run() {
Looper.prepare();

mHandler = new Handler();

Looper.loop();
}
}


On Jul 8, 12:41 am, fadden fad...@android.com wrote:
 On Jul 6, 6:43 am, TjerkW tje...@gmail.com wrote:

  Basically this stops me from properly implementing a background file
  upload.
  Anybody has an idea what is going on here?

 Looks like theheapis full.  What's taking up all that space?

 Is something catching and ignoring OOM?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Garbage Collection Infinit Loop: clamp GC FOR MALLOC Grow heap loop

2010-07-06 Thread TjerkW
I have a Service which uploads a big file to a webserver. This works
fine on the emulator (android 2.1).

But if i run it on a Nexus One Froyo phone it starts out fine. But
after a while it is in an infinite GC loop.
The whole phone becomes unusable:


07-06 11:56:28.916: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 60
07-06 11:56:28.987: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 60
07-06 11:56:28.987: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 60
07-06 11:56:29.057: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 60
07-06 11:56:29.057: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 60
07-06 11:56:29.127: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 61
07-06 11:56:29.127: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 61
07-06 11:56:29.196: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 61
07-06 11:56:29.196: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 61
07-06 11:56:29.476: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 25.533MB to 24.000MB
07-06 11:56:29.476: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 14048
objects / 515832 bytes in 240ms
07-06 11:56:29.497: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 61
07-06 11:56:29.497: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 61
07-06 11:56:29.567: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 61
07-06 11:56:29.567: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 61
07-06 11:56:29.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 25.791MB to 24.000MB
07-06 11:56:29.847: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 6001
objects / 217168 bytes in 235ms
07-06 11:56:29.877: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 62
07-06 11:56:29.877: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 62
07-06 11:56:30.157: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 25.911MB to 24.000MB
07-06 11:56:30.157: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 2591
objects / 92632 bytes in 241ms
07-06 11:56:30.407: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 25.964MB to 24.000MB
07-06 11:56:30.407: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 1044
objects / 36816 bytes in 224ms
07-06 11:56:30.407: VERBOSE/
HyvesUpload::mediaUpload::onProgress(2351): progress: 62
07-06 11:56:30.407: DEBUG/ImageUploadService(2351):
onPictureUploadProgress 62
07-06 11:56:30.657: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 25.982MB to 24.000MB
07-06 11:56:30.657: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 509
objects / 18232 bytes in 232ms
07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:30.897: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
objects / 0 bytes in 240ms
07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 28-byte allocation
07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:31.136: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
objects / 0 bytes in 233ms
07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 24-byte allocation
07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:31.377: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
objects / 0 bytes in 245ms
07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 28-byte allocation
07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:31.617: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
objects / 0 bytes in 234ms
07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 28-byte allocation
07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:31.847: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
objects / 0 bytes in 234ms
07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 28-byte allocation
07-06 11:56:32.097: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 11:56:32.097: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 1
objects / 32 bytes in 243ms
07-06 11:56:32.097: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 24.000MB to 24.000MB
07-06 11:56:32.097: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
24.000MB for 8-byte allocation
07-06 11:56:32.337: INFO/dalvikvm-heap(1872): Clamp target GC heap
from 26.000MB to 24.000MB
07-06 

[android-developers] Re: Garbage Collection Infinit Loop: clamp GC FOR MALLOC Grow heap loop

2010-07-06 Thread TjerkW
Basically this stops me from properly implementing a background file
upload.
Anybody has an idea what is going on here?

On Jul 6, 12:02 pm, TjerkW tje...@gmail.com wrote:
 I have a Service which uploads a big file to a webserver. This works
 fine on the emulator (android 2.1).

 But if i run it on a Nexus One Froyo phone it starts out fine. But
 after a while it is in an infinite GC loop.
 The whole phone becomes unusable:

 07-06 11:56:28.916: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 60
 07-06 11:56:28.987: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 60
 07-06 11:56:28.987: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 60
 07-06 11:56:29.057: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 60
 07-06 11:56:29.057: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 60
 07-06 11:56:29.127: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 61
 07-06 11:56:29.127: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 61
 07-06 11:56:29.196: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 61
 07-06 11:56:29.196: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 61
 07-06 11:56:29.476: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 25.533MB to 24.000MB
 07-06 11:56:29.476: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 14048
 objects / 515832 bytes in 240ms
 07-06 11:56:29.497: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 61
 07-06 11:56:29.497: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 61
 07-06 11:56:29.567: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 61
 07-06 11:56:29.567: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 61
 07-06 11:56:29.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 25.791MB to 24.000MB
 07-06 11:56:29.847: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 6001
 objects / 217168 bytes in 235ms
 07-06 11:56:29.877: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 62
 07-06 11:56:29.877: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 62
 07-06 11:56:30.157: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 25.911MB to 24.000MB
 07-06 11:56:30.157: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 2591
 objects / 92632 bytes in 241ms
 07-06 11:56:30.407: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 25.964MB to 24.000MB
 07-06 11:56:30.407: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 1044
 objects / 36816 bytes in 224ms
 07-06 11:56:30.407: VERBOSE/
 HyvesUpload::mediaUpload::onProgress(2351): progress: 62
 07-06 11:56:30.407: DEBUG/ImageUploadService(2351):
 onPictureUploadProgress 62
 07-06 11:56:30.657: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 25.982MB to 24.000MB
 07-06 11:56:30.657: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 509
 objects / 18232 bytes in 232ms
 07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:30.897: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
 objects / 0 bytes in 240ms
 07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 24.000MB to 24.000MB
 07-06 11:56:30.897: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
 24.000MB for 28-byte allocation
 07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:31.136: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
 objects / 0 bytes in 233ms
 07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 24.000MB to 24.000MB
 07-06 11:56:31.136: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
 24.000MB for 24-byte allocation
 07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:31.377: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
 objects / 0 bytes in 245ms
 07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 24.000MB to 24.000MB
 07-06 11:56:31.377: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
 24.000MB for 28-byte allocation
 07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:31.617: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
 objects / 0 bytes in 234ms
 07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 24.000MB to 24.000MB
 07-06 11:56:31.617: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
 24.000MB for 28-byte allocation
 07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:31.847: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 0
 objects / 0 bytes in 234ms
 07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 24.000MB to 24.000MB
 07-06 11:56:31.847: INFO/dalvikvm-heap(1872): Grow heap (frag case) to
 24.000MB for 28-byte allocation
 07-06 11:56:32.097: INFO/dalvikvm-heap(1872): Clamp target GC heap
 from 26.000MB to 24.000MB
 07-06 11:56:32.097: DEBUG/dalvikvm(1872): GC_FOR_MALLOC freed 1
 objects / 32 bytes in 243ms
 07-06 11:56:32.097: INFO

[android-developers] Re: Time keeping in a game thread

2010-01-14 Thread TjerkW
System.currentTimeMillis is not the correct way to go for games, it
changes if the users changes the time on the phone.
Use SystemClock.uptimeMillis

http://developer.android.com/reference/android/os/SystemClock.html#uptimeMillis()

On Jan 14, 7:14 pm, Robert Green rbgrn@gmail.com wrote:
 private long tickMs;
 private long lastTickMs;
 private long tickDeltaMs;

 public void run() {
   while (running) {
     lastTickMs = tickMs;
     tickMs = System.currentTimeMillis();
     tickDeltaMs = tickMs - lastTickMs;
     updateGame(tickDeltaMs);
   }

 }

 That's all you need.  I've found that the actual tick time doesn't
 matter but the difference between the last tick and this tick is all
 you need to have correct physics and most any update I've had to write
 so far.

 Game physics can work like this

 updateGame(12) // moves physics 12ms forward
 updateGame(15) // moves physics 15ms forward
 updateGame(22) // moves physics 22ms forward

 That's exactly what you want the tick delta for.  I use that for all
 movement, sound, collisions, animations and timers.

 There's one exception - if your game cares about time of day.  Then
 you need the actual time of day calculated out to use for it, but
 otherwise if the game runs in its own time, that'll do.

 On Jan 14, 7:02 am, Neilz neilhorn...@googlemail.com wrote:



  Hi all. What is most efficient way of keeping a check on time within a
  game thread?

  Currently I create a new Date() when the game starts, and was thinking
  of creating another Date() within the game thread and comparing it
  with the first one. But with a screen refreshing at around 60fps
  (hence a new date object each time), I can't help thinking this is
  rather inefficient. What other ways are there of doing this?
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Live Wallpaper Tutorial

2010-01-12 Thread TjerkW
Android 2.1 has API support for creating live wallpapers. This means
that we can implemente our own live wallpapers w00t!

However what i like to see is a Tutorial on creating such a live
wallpaper.
Is there going to be added one?
What about battery live?

Or maybe a link to the sourcecode to one of the live wallpapers in
Nexus One?

When i run a 2.1 emulator and choose a live wallpaper it says: No
live wallpapers

--
Anyway thanks for this nice peace of software.
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Emulator: LogCat Errors for Donut 1.6 Release

2009-10-12 Thread TjerkW

Sorry but the

10-12 23:42:28.195: ERROR/GLLogger(709): couldn't load libhgl.so
library (Cannot find library)

error message seems important.

In my application i try to start open gl but i get the following
errors:

10-12 23:42:28.005: DEBUG/AirAttackActivity(709): Launching Game
Activity
10-12 23:42:28.195: ERROR/GLLogger(709): couldn't load libhgl.so
library (Cannot find library)
10-12 23:42:28.225: DEBUG/SpaceWarsActivity(709): onStart
10-12 23:42:28.315: DEBUG/dalvikvm(709): GC freed 1201 objects / 71768
bytes in 81ms
10-12 23:42:28.345: DEBUG/SpaceWarsActivity(709): onResume
10-12 23:42:28.405: DEBUG/GLGame(709): Waiting for GL Surface to be
created...
10-12 23:42:28.546: DEBUG/SurfaceFlinger(568): pid 709 requesting gpu
surface (current owner = -1)
10-12 23:42:28.546: ERROR/MemoryHeapBase(568): error opening /dev/
pmem_gpu0: No such file or directory
10-12 23:42:28.546: ERROR/MemoryHeapBase(568): error opening /dev/
pmem_gpu1: No such file or directory
10-12 23:42:28.546: ERROR/MemoryHeapBase(568): error opening /dev/
hw3d: No such file or directory
10-12 23:42:28.557: DEBUG/SurfaceFlinger(568): pid 709 requesting gpu
surface (current owner = -1)
10-12 23:42:28.557: ERROR/MemoryHeapBase(568): error opening /dev/
pmem_gpu0: No such file or directory
10-12 23:42:28.557: ERROR/MemoryHeapBase(568): error opening /dev/
pmem_gpu1: No such file or directory
10-12 23:42:28.557: ERROR/MemoryHeapBase(568): error opening /dev/
hw3d: No such file or directory
10-12 23:42:28.596: DEBUG/GLGame(709): GL Surface Created
10-12 23:42:28.606: DEBUG/GL(709): Loading texture
10-12 23:42:28.646: DEBUG/GL(709): Texture name: 0
10-12 23:42:28.646: ERROR/GL(709): Texture Load GLError: 2025968
10-12 23:42:28.646: DEBUG/GL(709): textImage2D
10-12 23:42:28.666: ERROR/GL(709): Texture Load GLError: 2025968
10-12 23:42:28.666: ERROR/GL(709): Texture Load GLError: 2025968
10-12 23:42:28.666: DEBUG/GL(709): Adding texture info: 60x60
10-12 23:42:28.706: DEBUG/GL(709): Loading texture


On Sep 16, 8:14 am, Romain Guy romain...@google.com wrote:
 You can ignore these.





 On Tue, Sep 15, 2009 at 9:30 PM, kk kkru...@gmail.com wrote:

  Hi All,

  The following errors occurred during startup of Android 1.6 SDK
  Release Emulator:

  What do the following errors mean?

  Can these errors be ignored?

  Emulator Details:

  Target: Google APIs (API Level 4)
  Skin: HVGA
  SDCARD: 64MB  image size

  Errors:

  09-16 13:16:00.072: ERROR/vold(550): Error opening switch name path '/
  sys/class/switch/test2' (No such file or directory)
  09-16 13:16:00.072: ERROR/vold(550): Error bootstrapping switch '/sys/
  class/switch/test2' (No such file or directory)
  09-16 13:16:00.072: ERROR/vold(550): Error opening switch name path '/
  sys/class/switch/test' (No such file or directory)
  09-16 13:16:00.072: ERROR/vold(550): Error bootstrapping switch '/sys/
  class/switch/test' (No such file or directory)
  09-16 13:16:54.123: ERROR/MemoryHeapBase(582): error opening /dev/
  pmem: No such file or directory
  09-16 13:16:54.133: ERROR/SurfaceFlinger(582): Couldn't open /sys/
  power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
  09-16 13:16:54.312: ERROR/libEGL(582): couldn't load libhgl.so
  library (Cannot load library: load_library[984]: Library 'libhgl.so'
  not found)
  09-16 13:16:56.602: ERROR/libEGL(598): couldn't load libhgl.so
  library (Cannot load library: load_library[984]: Library 'libhgl.so'
  not found)
  09-16 13:17:17.392: ERROR/BatteryService(582): Could not open '/sys/
  class/power_supply/usb/online'
  09-16 13:17:17.392: ERROR/BatteryService(582): Could not open '/sys/
  class/power_supply/battery/batt_vol'
  09-16 13:17:17.401: ERROR/BatteryService(582): Could not open '/sys/
  class/power_supply/battery/batt_temp'
  09-16 13:17:19.242: ERROR/EventHub(582): could not get driver version
  for /dev/input/mouse0, Not a typewriter
  09-16 13:17:19.271: ERROR/EventHub(582): could not get driver version
  for /dev/input/mice, Not a typewriter
  09-16 13:17:19.852: ERROR/System(582): Failure starting core service
  09-16 13:17:19.852: ERROR/System(582): java.lang.SecurityException
  09-16 13:17:19.852: ERROR/System(582):     at
  android.os.BinderProxy.transact(Native Method)
  09-16 13:17:19.852: ERROR/System(582):     at
  android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:
  146)
  09-16 13:17:19.852: ERROR/System(582):     at
  android.os.ServiceManager.addService(ServiceManager.java:72)
  09-16 13:17:19.852: ERROR/System(582):     at
  com.android.server.ServerThread.run(SystemServer.java:162)
  09-16 13:17:19.892: ERROR/AndroidRuntime(582): Crash logging skipped,
  no checkin service
  09-16 13:17:26.013: ERROR/LockPatternKeyguardView(582): Failed to bind
  to GLS while checking for account

  Thanks,
  KK

 --
 Romain Guy
 Android framework engineer
 romain...@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 

[android-developers] Re: SurfaceView to slow for games? OpenGL necessary to do games?

2009-08-24 Thread TjerkW

The SpriteMethodTest application shows the benefits of opengl,
the main benefit is:

If you have a lot of sprites / a lot of things happening at the same
time it is better to use opengl.
I am porting my game to opengl now. It was too slow on only the Canvas
(30+ things moving at the same time)

On 22 jul, 12:45, MrChaz mrchazmob...@googlemail.com wrote:
 The SurfaceView is fine for games, at least simple ones.
 Have a look at the LunarLander sample.

 http://developer.android.com/guide/samples/LunarLander/index.html

 On Jul 21, 9:33 pm, klirr haskell...@gmail.com wrote:



  I use SurfaceView for my game, tried normal View first but that was to
  slow.
  Problem is, it still is. The redrawing just isn't anywhere fast enough
  for a game. So unless it is a lot faster on the real phone this won't
  cut it at all.
  Is it necessary to use OpenGL for games?

  package com.android.shmup;

  import android.app.Activity;
  import android.content.Context;
  import android.graphics.*;
  import android.os.Bundle;
  import android.view.View;
  import android.view.KeyEvent;

  public class Shmup extends Activity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(new GameView(this));
      }

      private static class GameView extends View {
          private Paint mPaint = new Paint();
          private int x;
          private int y;

          public GameView(Context context) {
              super(context);
              x = 135;
              y = 303;
              setFocusable(true);
              requestFocus();
          }

          @Override
          protected void onDraw(Canvascanvas) {
              Paint paint = mPaint;
             canvas.translate(10, 10);
             canvas.drawColor(Color.rgb(184,134,11));
              paint.setColor(Color.rgb(107,142,35));
              paint.setStrokeWidth(1);
             canvas.drawRect(x, y, x+30, y+7, paint);
             canvas.drawRect(x+10, y+7, x+20, y+27, paint);
             canvas.drawRect(x+5, y+27, x+25, y+32, paint);
          }

          @Override
          public boolean onKeyDown(int keyCode, KeyEvent event) {
                  if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
                          y -= 3;
                          invalidate();
                  } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
                          x -= 3;
                          invalidate();
                  } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
                          y += 3;
                          invalidate();
                  } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
                          x += 3;
                          invalidate();
                  }
                  return true;
          }

      }

  }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Game using Canvas porting to OpenGL please help

2009-06-30 Thread TjerkW

Nobody can help me?

On 18 jun, 14:12, TjerkW tje...@gmail.com wrote:
 Hello All,

 My game runs fairly well on my phone, but i want to increase the
 performance by usingopengl.
 However currently i use the Canvas.
 I am a beginner inopengl.
 I have to port all my drawing code toopengl. However can somebody
 give me directions.
 For example how do i do the following inopengl:

                         c.save();
                         c.scale(0.3f+scale, 0.3f+scale, width/2, height/2);
                         c.drawBitmap(
                                         bMsg.bitmap,
                                 width/2 - bMsg.bitmap.getWidth()/2,
                                 dy+height/2 - bMsg.bitmap.getHeight()/2,
                                 MESSAGE_PAINT
                         );
                         c.restore();

 And why cant i just use Canvas as an abstraction layer (facade) foropengl.
 An implementation of canvas could call the correctopenglmethods in
 order to render.
 Why do i have to port all my code. I thought the canvas was a good
 abstraction interface to a drawing surface,
 why do i have to bother withopengl?

 It looks like this is possible, when is see the following contructor:
 public Canvas (GL gl)
 Also the this seems usefull.
 SURFACE_TYPE_GPU        Surface type: creates a surface suited to be used
 with the GPU

 So what should i do?
 Re implementing the GamePainter completely and callopenglfunctions
 directly?
 Or is there some kind of abstraction mechanism, so that i can useOpenGLwith 
 just a few lines of code?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Game using Canvas porting to OpenGL please help

2009-06-18 Thread TjerkW

Hello All,

My game runs fairly well on my phone, but i want to increase the
performance by using opengl.
However currently i use the Canvas.
I am a beginner in opengl.
I have to port all my drawing code to opengl. However can somebody
give me directions.
For example how do i do the following in opengl:

c.save();
c.scale(0.3f+scale, 0.3f+scale, width/2, height/2);
c.drawBitmap(
bMsg.bitmap,
width/2 - bMsg.bitmap.getWidth()/2,
dy+height/2 - bMsg.bitmap.getHeight()/2,
MESSAGE_PAINT
);
c.restore();

And why cant i just use Canvas as an abstraction layer (facade) for
opengl.
An implementation of canvas could call the correct opengl methods in
order to render.
Why do i have to port all my code. I thought the canvas was a good
abstraction interface to a drawing surface,
why do i have to bother with opengl?

It looks like this is possible, when is see the following contructor:
public Canvas (GL gl)
Also the this seems usefull.
SURFACE_TYPE_GPUSurface type: creates a surface suited to be used
with the GPU

So what should i do?
Re implementing the GamePainter completely and call opengl functions
directly?
Or is there some kind of abstraction mechanism, so that i can use
OpenGL with just a few lines of code?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Application Resources on SDCARD on install!! MUST HAVE, GOOGLE DO SOMETHING!!

2009-06-15 Thread TjerkW

Reset the title of this post,..
You really ruined this post though

On 14 jun, 15:02, javaumesh-andr...@yahoo.co.in wrote:
 Hi all

 I have a an activity which has an image view to display animation. and I'm 
 reading resources from res/anim which is working absolutely fine.  But what 
 I'm trying is to specify the frames at run time instead of hard coding at the 
 res/anim/file.xml  any idea. ?

 Following works fine.

    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         setContentView(R.layout.main);
         mImageView = (ImageView)this.findViewById(R.id.AdImageView);
         mImageView.setImageResource(R.anim.adlist);
         adDisplay = (AnimationDrawable)mImageView.getDrawable();
               }

     @Override
     public void onWindowFocusChanged(boolean hasFocus) {
         super.onWindowFocusChanged(hasFocus);
         if(hasFocus== true){
             adDisplay.start();
          }

 and the  adlist.xml is :

 ?xml version=1.0 encoding=UTF-8?

     item android:drawable=@drawable/ad_01 android:duration=500 /
     item android:drawable=@drawable/ad_02 android:duration=500 /
 /animation-list

 But what I wan't is I wan't to create the AnimationDrawable object at runtime 
 not from the xml source,as my requirement is no of frames and *.png files may 
 change at the runtime.

 I tried the following it I'm unable to get the expected result.

 @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         mImageView = (ImageView)this.findViewById(R.id.AdImageView);
         adDisplay = new AnimationDrawable();
         
 adDisplay.addFrame(Drawable.createFromPath(/data/data/com.example.ad/files 
 /ad_01.png),500 );
         
 adDisplay.addFrame(Drawable.createFromPath(/data/data/com.example.ad/files 
 /ad_02.png),500 );
         mImageView.setImageDrawable(adDisplay);

               }

 Any thing I'm missing in the implementation ?

       Own a website.Get an unlimited package.Pay next to nothing.*Go 
 tohttp://in.business.yahoo.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Strategies for alerting users about new versions of your app in the appstore?

2009-06-14 Thread TjerkW

This is al implemented in the Android market and it comes for free
when publishing your app in the market.
And any is evert body staking about an app store, ita called the
Android market
On 14 jun, 05:30, pawpaw17 georgefraz...@yahoo.com wrote:
 Guys,

 Is there a methodology for pushing out new versions of appstore apps
 to customers in Android/or via the appstore? Or is this something each
 app needs to cook up for itself?

 Thanks!

 pawpaw17
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Application Resources on SDCARD on install!! MUST HAVE, GOOGLE DO SOMETHING!!

2009-06-14 Thread TjerkW

A lot of developers and this problem:
All resources in an APK are stored in the memory of the phone,
it is impossible to force some resources to be saved on the sdcard.

For example, check this use-case:
I am creating a game with multiple levels a lot of sounds, menumusic
and sprites.
The size unpacked is now 6MB and the game is not even finished
Users are already complaining:
http://www.cyrket.com/package/com.tjerk.spacewars


The only current solution is to download the data after installation
on the sdcard and load the data from the sd card (requires your own
data handling code, the convenience R class cannot be used).
This solution is a no-go for a lot of developers because they simply
donot have a server. The users may also find it weird that they have
to install stuff after they installed the app.

Another solution is to have a linux partition on your sdcard, but this
requires a rooted phone and is only for advanced users.

I know they are a lot of issues with installing part of the app on the
sdcard (piracy etc). However if you only install application data on
the sdcard, then there would be no problem. I suggest to create a
.appname directory for each application that requires to save
resources on the sdcard. Window users will not see that directory. If
they delete the directory and restart the app they should get an
alertbox that forces them to reinstall (or remove) the app.

Seriouzly google, you have to add a feature that solves this problem,
the android platform is a no-go for big games. And users can install a
limited number of apps.

What i want to now: Is this going to be implemented in the future?
Or should i implemented the download-from-server solution. If you
are going to implemented it in the next release than i will not waste
time on implementing the download-from-server solution.

Links to other posts of developers that have the same problem:
http://groups.google.com/group/android-developers/browse_thread/thread/9ab3c62274aff2a1/e79c251bdf60ed97?lnk=gstq=application+size#e79c251bdf60ed97
http://groups.google.com/group/android-developers/browse_thread/thread/ca9e824d8451871a/8ffc708d4d87a9a2?lnk=gstq=application+size#8ffc708d4d87a9a2
http://groups.google.com/group/android-developers/browse_thread/thread/8251f0d6ca7f7ecb/311b4ff59bf8dab7?lnk=gstq=resources+on+sdcard#311b4ff59bf8dab7
http://groups.google.com/group/android-developers/browse_thread/thread/381e652ae1b3693a/2f9ffd68ad98ae57?lnk=gstq=resources+on+sdcard#2f9ffd68ad98ae57
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Application Resources on SDCARD on install!! MUST HAVE, GOOGLE DO SOMETHING!!

2009-06-14 Thread TjerkW

B.t.w:
Dianne Hackborn already gave some usefull comments in this thread:
http://groups.google.com/group/android-developers/browse_thread/thread/9ab3c62274aff2a1/e79c251bdf60ed97?lnk=gstq=application+size#e79c251bdf60ed97

However i need more info. Is this going to be implemented in the
future or not? If so.. when?
I would also like to know the googles opinion about this issue.

For people that want to implemented the download-after-install
solution, look here for code examples:
http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Samples/Downloader/src

On 14 jun, 12:26, TjerkW tje...@gmail.com wrote:
 A lot of developers and this problem:
 All resources in an APK are stored in the memory of the phone,
 it is impossible to force some resources to be saved on the sdcard.

 For example, check this use-case:
 I am creating a game with multiple levels a lot of sounds, menumusic
 and sprites.
 The size unpacked is now 6MB and the game is not even finished
 Users are already 
 complaining:http://www.cyrket.com/package/com.tjerk.spacewars

 The only current solution is to download the data after installation
 on the sdcard and load the data from the sd card (requires your own
 data handling code, the convenience R class cannot be used).
 This solution is a no-go for a lot of developers because they simply
 donot have a server. The users may also find it weird that they have
 to install stuff after they installed the app.

 Another solution is to have a linux partition on your sdcard, but this
 requires a rooted phone and is only for advanced users.

 I know they are a lot of issues with installing part of the app on the
 sdcard (piracy etc). However if you only install application data on
 the sdcard, then there would be no problem. I suggest to create a
 .appname directory for each application that requires to save
 resources on the sdcard. Window users will not see that directory. If
 they delete the directory and restart the app they should get an
 alertbox that forces them to reinstall (or remove) the app.

 Seriouzly google, you have to add a feature that solves this problem,
 the android platform is a no-go for big games. And users can install a
 limited number of apps.

 What i want to now: Is this going to be implemented in the future?
 Or should i implemented the download-from-server solution. If you
 are going to implemented it in the next release than i will not waste
 time on implementing the download-from-server solution.

 Links to other posts of developers that have the same 
 problem:http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Accelerometer/Orientation sensor problem

2009-06-11 Thread TjerkW

Nope this problem is is also on the htc magic .. check my post for a
solution using a damper. Somewhere else in this group ...

On 11 jun, 22:28, Sundog sunns...@gmail.com wrote:
 I'd be very interested to know if anyone besides G1 owners has seen
 this? My best guess is that it's a design flaw specific to this
 phone... and if so, no fix will be forthcoming.

 On Jun 11, 2:20 pm, Sundog sunns...@gmail.com wrote:



  Just a me too to report that this problem is real and is still here
  under Cupcake. Play a sound and the accelerometer goes haywire for a
  second. Only fix I can see is ignoring the accelerometer while SFX are
  playing... kinda not really a good workaround for a game.

  On Jun 8, 8:25 am, TjerkW tje...@gmail.com wrote:

   Sameproblemhere,

   when playing sounds during my game (in which you control the gameplay
   withaccelerometer)
   theaccelerometergives strange values.

   On 24 mei, 13:29, Bonifaz bonifaz.kaufm...@gmail.com wrote:

I have the sameproblemof wiredaccelerometerdata while music is
playing.

Does anyone have a workaround for this. Some kind of filter mechanism
perhaps.

I use FloatMath.sqrt(x*x + y*y + z*z) for shake detection.
But even with that formular, playing music always detects shake,
just raising the threshold won't work, since shake would not be
detected with to high threshold.- Hide quoted text -

   - Show quoted text -- Hide quoted text -

  - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Android Market Automatic Updates

2009-06-11 Thread TjerkW

When i update my application in the android market..
Will users be automatically notified to download a new version?

I just implemented veecheck for my game.. (http://www.tomgibara.com/
android/veecheck/)
but that was all wasted time if it is already implemented.

Can somebody confirm this?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Sounds + Accelerometer = Weird accelerometer values: BUG?

2009-06-09 Thread TjerkW

I am developing a game.
In which the user controls movement using the accelerometer.
Sounds effects can also be enabled.

However when laying the phone flat down and playing the game without
the accelerometer gives nice 0,0,0 values.

However when play WITH SOUNDS on, i get a buch of weird values: while
the phone is NOT moving.

This is really a big bug that makes life hard for Game Developers.
I tried to take an avarge of the last 5 values from the sensor.. but
this is not enough..

The harder the sounds plays: the higher the weird sensor values.

When using the headphones: almost no weird values.


Seems that sounds interferes with the accelerometer sensor.

BTW: more developers posted this issue but no reactions at all from
google!!
http://groups.google.com/group/android-developers/browse_thread/thread/e1a67f197173abb5#
http://groups.google.com/group/android-developers/browse_thread/thread/324a61badc59d58f/bc1e45433da68ce7

Is this is hardware problem?
How do i solve it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Sounds + Accelerometer = Weird accelerometer values: BUG?

2009-06-09 Thread TjerkW

I am trying to solve this problem myself...
I created a class that damps the values over a window of previous
sensor values.

However with a damping wndow of 6 frames i still have the weird
values.

Here some logcat output of the damped values:
The phone was just laying on my table.. not moving...!
(The strange values are visble after the sound is played)


06-09 21:13:49.314: DEBUG/GameController(1104): D Azi,Pitch,Roll:
315,-2,1
06-09 21:13:49.334: DEBUG/GameController(1104): D Azi,Pitch,Roll:
316,-2,1
06-09 21:13:49.374: DEBUG/GameController(1104): D Azi,Pitch,Roll:
316,-2,1
06-09 21:13:49.414: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,-2,1
06-09 21:13:49.434: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,-2,1
06-09 21:13:49.464: DEBUG/GameController(1104): D Azi,Pitch,Roll:
318,-2,1
06-09 21:13:49.494: INFO/SoundEffects(1104): Playing:
2131099658 -- playing sound
here
06-09 21:13:49.574: DEBUG/GameController(1104): D Azi,Pitch,Roll:
318,-2,2
06-09 21:13:49.594: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,0,3
06-09 21:13:49.614: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,0,3
06-09 21:13:49.634: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,0,4
06-09 21:13:49.654: DEBUG/GameController(1104): D Azi,Pitch,Roll:
317,0,1-- dampnig prevents very high
extreme sensor values
06-09 21:13:49.674: DEBUG/GameController(1104): D Azi,Pitch,Roll:
316,-1,0
06-09 21:13:49.694: DEBUG/GameController(1104): D Azi,Pitch,Roll:
316,-2,-2
06-09 21:13:49.714: DEBUG/GameController(1104): D Azi,Pitch,Roll:
315,-6,-6
06-09 21:13:49.734: DEBUG/GameController(1104): D Azi,Pitch,Roll:
314,-7,-9
06-09 21:13:49.754: DEBUG/GameController(1104): D Azi,Pitch,Roll:
314,-12,-15
06-09 21:13:49.774: DEBUG/GameController(1104): D Azi,Pitch,Roll:
313,-11,-18-- however still
strange values here
06-09 21:13:49.794: DEBUG/GameController(1104): D Azi,Pitch,Roll:
313,-7,-16
06-09 21:13:49.814: DEBUG/GameController(1104): D Azi,Pitch,Roll:
311,-1,-13
06-09 21:13:49.834: DEBUG/GameController(1104): D Azi,Pitch,Roll:
307,7,-9
06-09 21:13:49.854: DEBUG/GameController(1104): D Azi,Pitch,Roll:
302,13,-3
06-09 21:13:49.873: DEBUG/GameController(1104): D Azi,Pitch,Roll:
295,22,2
06-09 21:13:49.894: DEBUG/GameController(1104): D Azi,Pitch,Roll:
285,24,12
06-09 21:13:49.914: DEBUG/GameController(1104): D Azi,Pitch,Roll:
273,23,16
06-09 21:13:49.933: DEBUG/GameController(1104): D Azi,Pitch,Roll:
259,22,15
06-09 21:13:49.964: DEBUG/GameController(1104): D Azi,Pitch,Roll:
244,17,14
06-09 21:13:49.984: DEBUG/GameController(1104): D Azi,Pitch,Roll:
231,14,10
06-09 21:13:50.004: DEBUG/GameController(1104): D Azi,Pitch,Roll:
219,9,8
06-09 21:13:50.024: DEBUG/GameController(1104): D Azi,Pitch,Roll:
209,5,4



If you want i can post the damping class online
( i wrote it so it can easily be reused )

On 9 jun, 20:08, TjerkW tje...@gmail.com wrote:
 I am developing a game.
 In which the user controls movement using the accelerometer.
 Sounds effects can also be enabled.

 However when laying the phone flat down and playing the game without
 the accelerometer gives nice 0,0,0 values.

 However when play WITH SOUNDS on, i get a buch of weird values: while
 the phone is NOT moving.

 This is really a big bug that makes life hard for Game Developers.
 I tried to take an avarge of the last 5 values from the sensor.. but
 this is not enough..

 The harder the sounds plays: the higher the weird sensor values.

 When using the headphones: almost no weird values.

 Seems that sounds interferes with the accelerometer sensor.

 BTW: more developers posted this issue but no reactions at all from
 google!!http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...

 Is this is hardware problem?
 How do i solve it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Sounds + Accelerometer = Weird accelerometer values: BUG?

2009-06-09 Thread TjerkW

Here is my damper.

HOWEVER: IT DOES NOT SOLVE THIS PROBLEM.
I am going to set the damping windows size to 3 or 4,
however i will disable sound because gameplay is practically
impossible with sounds on.


So Google Developers:  What is causing this problem,
and how is it solved.???



Here my sensor damper:



package com.tjerk.util;


/**
 * Class that adapts the sensor output values
 * by damping them over an window of previous sensor values.
 *
 * The new sensor values are the average over all sensor values
 * in the window.
 *
 * This class can be used as a workaround for the
 * accelerometer sensor+sound bug in Android.
 *
 * A biger window means less fluctuation in the sensor values.
 * However a side-effect of a large window is that it takes
 * there is a delay in movement detection.
 *
 * @author Tjerk Wolterink
 * @date June 9, 2009
 */
public class SensorAverageDamper {
private float[] window0;
private float[] window1;
private float[] window2;
private int i;
private int windowSize;

/**
 * Creates an sensor damper with a specific window size.
 *
 * @param windowSize the of the average window
 */
public SensorAverageDamper(int windowSize) {
this(windowSize, true, true, true);
}


/**
 * Creates a new damper with a specific window size.
 *
 * @param windowSize the of the average window
 * @param damp0 wether to damp sensor value values[0]
 * @param damp1 wether to damp sensor value values[1]
 * @param damp1 wether to damp sensor value values[1]
 */
public SensorAverageDamper(int windowSize, boolean damp0, boolean
damp1, boolean damp2) {
this.windowSize=windowSize;
if(damp0) window0=createWindow();
if(damp1) window1=createWindow();
if(damp2) window2=createWindow();
}

protected float[] createWindow() {
float[] w=new float[windowSize];
for(int i=0;iw.length;i++) w[i]=-1;
return w;
}

protected float average(float[] w) {
int l=0;
int j=i;
float sum=0;
while(true) {
if(w[j]!=-1) {
l++;
sum+=w[j];
}
j=(j+1)%w.length;
if(j==i) break;
}
return sum/l;
}

/**
 * Adds the values to the window and
 * returns the damped values (average in the window)
 * @param values
 * @return
 */
public float[] damp(float[] values) {
i=(i+1)%windowSize;
if(window0!=null) {
window0[i]=values[0];
values[0]=average(window0);
}
if(window1!=null) {
window1[i]=values[1];
values[1]=average(window1);
}
if(window2!=null) {
window2[i]=values[2];
values[2]=average(window2);
}
return values;
}
}




On 9 jun, 20:08, TjerkW tje...@gmail.com wrote:
 I am developing a game.
 In which the user controls movement using the accelerometer.
 Sounds effects can also be enabled.

 However when laying the phone flat down and playing the game without
 the accelerometer gives nice 0,0,0 values.

 However when play WITH SOUNDS on, i get a buch of weird values: while
 the phone is NOT moving.

 This is really a big bug that makes life hard for Game Developers.
 I tried to take an avarge of the last 5 values from the sensor.. but
 this is not enough..

 The harder the sounds plays: the higher the weird sensor values.

 When using the headphones: almost no weird values.

 Seems that sounds interferes with the accelerometer sensor.

 BTW: more developers posted this issue but no reactions at all from
 google!!http://groups.google.com/group/android-developers/browse_thread/threa...http://groups.google.com/group/android-developers/browse_thread/threa...

 Is this is hardware problem?
 How do i solve it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Sounds + Accelerometer = Weird accelerometer values: BUG?

2009-06-09 Thread TjerkW

You mean trying not to hold my hand near the speakers?

This does not solve anything.
Problem still there.

BTW: i am using an HTC Magic phone.
I know this strange behaviour is also on the HTC Dream (g1)

On 9 jun, 20:18, Satish Bellapu satishbabu...@gmail.com wrote:
 I feel this is the hardware issue, because of the speaker which is place in
 back side,
 on playing the sound because of the vibrations the accelerometer is giving
 these values.

 Try to hold the phone with out putting any surface closed to the speaker
 holes, then u will not get these wired values.

 I tried its working :).



 On Tue, Jun 9, 2009 at 11:38 PM, TjerkW tje...@gmail.com wrote:

  I am developing a game.
  In which the user controls movement using the accelerometer.
  Sounds effects can also be enabled.

  However when laying the phone flat down and playing the game without
  the accelerometer gives nice 0,0,0 values.

  However when play WITH SOUNDS on, i get a buch of weird values: while
  the phone is NOT moving.

  This is really a big bug that makes life hard for Game Developers.
  I tried to take an avarge of the last 5 values from the sensor.. but
  this is not enough..

  The harder the sounds plays: the higher the weird sensor values.

  When using the headphones: almost no weird values.

  Seems that sounds interferes with the accelerometer sensor.

  BTW: more developers posted this issue but no reactions at all from
  google!!

 http://groups.google.com/group/android-developers/browse_thread/threa...

 http://groups.google.com/group/android-developers/browse_thread/threa...

  Is this is hardware problem?
  How do i solve it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Accelerometer/Orientation sensor problem

2009-06-08 Thread TjerkW

Same problem here,

when playing sounds during my game (in which you control the gameplay
with accelerometer)
the accelerometer gives strange values.

On 24 mei, 13:29, Bonifaz bonifaz.kaufm...@gmail.com wrote:
 I have the same problem of wired accelerometer data while music is
 playing.

 Does anyone have a workaround for this. Some kind of filter mechanism
 perhaps.

 I use FloatMath.sqrt(x*x + y*y + z*z) for shake detection.
 But even with that formular, playing music always detects shake,
 just raising the threshold won't work, since shake would not be
 detected with to high threshold.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to change the AlertDialog's background color?

2009-06-02 Thread TjerkW

Look into the themes.xml file that comes with the sdk..
it will take you some time to figure it out.. but its somewhere
there..

On 2 jun, 04:26, zhangxiyuan zhangzho...@gmail.com wrote:
 Hi,

 In Android, the AlertDialog's background color is light gray
 (#646464?), while I want to customize it to other color?
 I searched the groups and googled it online, and all about this is
 using style/theme to change that. I tried some solutions, but not
 succeeded.

 Anybody can give me a little more detailed solution?

 Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Dialog (built using AlertDialog.Builder) not complete when showing dialog in runOnUiThread

2009-05-31 Thread TjerkW

I have a game activity in which i have a dialog which is created in
the onCreateDialog method of the activity:

case VICTORY_DIALOG:

String[] items={Next Level, Play Again, 
Exit};

AlertDialog.Builder builder = new 
AlertDialog.Builder(this);
builder.setMessage(You won!)
.setCancelable(false)
.setItems(items, new 
DialogInterface.OnClickListener() {
public void onClick(DialogInterface 
dialog, int id) {
if(id==0) {

SpaceWarsActivity.this.nextLevel();
} else if(id==1) {

SpaceWarsActivity.this.loadGame();
} else if(id==2) {

SpaceWarsActivity.this.onFinishGame();
}
}
});
dialog=builder.create();
break;


When the game ends i open this dialog from the game thread (not the ui
thread) with the following code:

activity.runOnUiThread(new 
Runnable() {
public void run() {

activity.showDialog(VICTORY_DIALOG);
}
});

However... the dialog is just a small empty rectangle. No title, no
items, nothing!
The buttons (setPositiveButton,setNegativeButton,setNeutralButton) are
working though.

Wat am i doing wrong?

Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: sub-thread issue.

2009-05-31 Thread TjerkW

I created a game which also requires a gameloop thread.
I communicate with the thread simply by using getters and setters.
But that requires that the other threads has a the new thread as a
member instance.

I use the AsyncTask for loading levels, not for the game loop.

On 31 mei, 06:59, Gavin fjm...@gmail.com wrote:
 Hi,

      I have some questions about threads.
      Threre is a main thread A, and then it creats a sub-thread B. I
 want to know:
     1) If main thread A exits or crashs,  thread B can continue
 running?
     2) if the upper question's anwser is yes, is there a method that A
 can notify B before A exits? How can B get A's state?

     thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Dialog (built using AlertDialog.Builder) not complete when showing dialog in runOnUiThread

2009-05-31 Thread TjerkW
Ok i solved it myself.

I use setMessage together with setItems.. this does not work
One should use setTitle in stead of setMessage.

I think the builder show throw an exception if somebody uses
a illegal combination of parts (in my case: message + items)

Anyway its a small issue, but a nasty bug if you dont see it :-)

On 31 mei, 14:35, TjerkW tje...@gmail.com wrote:
 I have a game activity in which i have a dialog which is created in
 the onCreateDialog method of the activity:

         case VICTORY_DIALOG:

                                 String[] items={Next Level, Play Again, 
 Exit};

                                 AlertDialog.Builder builder = new 
 AlertDialog.Builder(this);
                                 builder.setMessage(You won!)
                                 .setCancelable(false)
                                 .setItems(items, new 
 DialogInterface.OnClickListener() {
                                         public void onClick(DialogInterface 
 dialog, int id) {
                                                 if(id==0) {
                                                         
 SpaceWarsActivity.this.nextLevel();
                                                 } else if(id==1) {
                                                         
 SpaceWarsActivity.this.loadGame();
                                                 } else if(id==2) {
                                                         
 SpaceWarsActivity.this.onFinishGame();
                                                 }
                                         }
                                 });
                                 dialog=builder.create();
                                 break;

 When the game ends i open this dialog from the game thread (not the ui
 thread) with the following code:

                                                 activity.runOnUiThread(new 
 Runnable() {
                                                         public void run() {
                                                                 
 activity.showDialog(VICTORY_DIALOG);
                                                         }
                                                 });

 However... the dialog is just a small empty rectangle. No title, no
 items, nothing!
 The buttons (setPositiveButton,setNegativeButton,setNeutralButton) are
 working though.

 Wat am i doing wrong?

 Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Possible bug when extending themes

2009-05-25 Thread TjerkW

I am extending a theme by creating a style.xml
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Possible bug when extending themes

2009-05-25 Thread TjerkW

I was typing and accidently pressed send

So here again the problem.

I have a styles.xml with the following content:

resources
style name=SpaceWarsTheme
parent=android:Theme.NoTitleBar.Fullscreen
item name=android:windowNoTitletrue/item
item name=android:textColorPrimary#FF00/item
item 
name=android:windowBackground@drawable/spacebackground/
item
  /style
/resources


However i get the following message in eclipse

The word ''@drawable is not correctly spelled

But that is nonsense!
I check the styles.xml that comes with android and found the following

item name=windowBackground@android:drawable/
screen_background_dark/item

However even this gives me the error message?!!@

What am i doing wrong?

On 25 mei, 23:17, TjerkW tje...@gmail.com wrote:
 I am extending a theme by creating a style.xml
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] SoundPool in Android 1.5: Still problems

2009-05-20 Thread TjerkW

A lot of developers where using the soundpool in 1.1:

http://groups.google.com/group/android-developers/browse_thread/thread/b84abc998ad02aa2/1a92b99355ae623f?lnk=gstq=SoundPool#1a92b99355ae623f
http://groups.google.com/group/android-developers/browse_thread/thread/e2f18cd7d53bcdfb/afb26f53697d222e?lnk=gstq=SoundPool#afb26f53697d222e

 In 1.5 it is nicely documented and Dave Sparks says the issues where
resolved in 1.5:
http://groups.google.com/group/android-developers/browse_thread/thread/b84abc998ad02aa2/1a92b99355ae623f?lnk=gstq=SoundPool#1a92b99355ae623f


However my game (with 10 sounds) shows some erattic behaviour when
using the soundpool. It looks like the sounds hiccup constantly. Also
the sensor does not react that fluently. You can see the behaviour
here:

http://www.youtube.com/watch?v=X2JF-Sdm6jUeurl=http://www.youtube.com/user/lmjabreufeature=player_embedded

The game works fine with the sounds turned of.. So probably this is a
performance problem?
I do not have a android phone now so i cant test it myself.
But somebody recognizes this behaviour?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] android.util.SparseArray space time complexity properties

2009-05-19 Thread TjerkW

I need a map from int to certain objects. I wanted to use the HashMap,
but in the documentation of SparseArray
it says that SparseArray is intented to be *more efficient*:
http://developer.android.com/reference/android/util/SparseArray.html

However i think the documentation is not entirely correct and needs
more info:
When reviewing the sourcecode of SparseArray and comparing it with the
HashMap i come to the following conclusion

Source code of Sparse Array:
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/util/SparseArray.java;hb=HEAD

For SpareArray:
Time complexity for reads and writes on a map of size N is log2(N) +
1,

However the time complexity for a HashMap of size N is C*N (where C is
a constant)
(according to the javadoc 
http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html)

So maybe SparseArray is more efficient with respect to space
complexity it is not for time complexity.
So for programs that need high performance a HashMap may be better.

At least thats what i think. Am i right? Am i wrong?
I need a very fast implementation for my game :-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Loading bitmap: java.lang.OutOfMemoryError: bitmap size

2009-05-18 Thread TjerkW

Somebody tested my game (see http://spacewarsgame.wordpress.com) on a
real device,
however occasionaly this exception is thrown when running the main
game Activity.
This activity loads a lot of resources in GamePainter.init.

(I know it is better to load resources in a separate thread, i'm
woking on it,
however this exception is unrelated to that (i think))

I dont now what the cause of this exception is, some VM memmory
allocation problem.
Is there not enough memory? If so, why does it run sometimes and other
times not?

The exception stack trace is below:


I/ActivityManager(   52): Starting activity: Intent {
comp={com.tjerk.spacewars/com.tjerk.spacewars.SpaceWarsActivity} }
D/AirAttackActivity(12208): Launching Game Activity
I/AirAttack(12208): Last conf instance: null
D/dalvikvm(12208): GC freed 7699 objects / 269024 bytes in 111ms
D/dalvikvm(12208): GC freed 347 objects / 14056 bytes in 84ms
E/dalvikvm-heap(12208): 1345600-byte external allocation too large for
this process.
E/(12208): VM won't let us allocate 1345600 bytes
D/AndroidRuntime(12208): Shutting down VM
W/dalvikvm(12208): threadid=3: thread exiting with uncaught exception
(group=0x4000fe68)
E/AndroidRuntime(12208): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(12208): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget
E/AndroidRuntime(12208):at
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(12208):at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:290)
E/AndroidRuntime(12208):at
android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:193)
E/AndroidRuntime(12208):at
android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:213)
E/AndroidRuntime(12208):at
com.tjerk.spacewars.GamePainter.init(GamePainter.java:186)
E/AndroidRuntime(12208):at
com.tjerk.spacewars.GameView.initialize(GameView.java:27)
E/AndroidRuntime(12208):at
com.tjerk.spacewars.SpaceWarsActivity.onCreate(SpaceWarsActivity.java:
47)
E/AndroidRuntime(12208):at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1122)
E/AndroidRuntime(12208):at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2104)
E/AndroidRuntime(12208):at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2157)
E/AndroidRuntime(12208):at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
E/AndroidRuntime(12208):at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1581)
E/AndroidRuntime(12208):at android.os.Handler.dispatchMessage
(Handler.java:88)
E/AndroidRuntime(12208):at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime(12208):at
android.app.ActivityThread.main(ActivityThread.java:3739)
E/AndroidRuntime(12208):at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(12208):at java.lang.reflect.Method.invoke
(Method.java:515)
E/AndroidRuntime(12208):at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
E/AndroidRuntime(12208):at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
E/AndroidRuntime(12208):at dalvik.system.NativeStart.main
(Native Method)
I/Process (   52): Sending signal. PID: 12208 SIG: 3
I/dalvikvm(12208): threadid=7: reacting to signal 3
I/dalvikvm(12208): Wrote stack trace to '/data/anr/traces.txt'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Animation Xml Resource and CycleInterpolator tag: FAIL

2009-05-16 Thread TjerkW

Euhm.. Then tell me why this class exists:
http://developer.android.com/reference/android/view/animation/CycleInterpolator.html

An i just follow the documentation for specifying interpolators:
http://developer.android.com/guide/topics/resources/available-resources.html#animation

By the way, i also checked this site:
http://developerlife.com/tutorials/?p=343

He speciffies interpolators with this xml attribute:
 android:interpolator=@android:anim/accelerate_interpolator

However when searching the internet is also see the following naming:
@android:anim/ease_in_interpolator

Are the ease_in ease_out just other names for the accelerate and
decelerate interpolators?
Or is this a refactoring done in android 1.5?

By the way.. i want to use the linear interpolator in my xml like
this:
android:interpolator=@android:anim/linear_interpolator

But then i get an error:  linear_interpolator is not public.. so
cannot use it.


So please help me out

On 14 mei, 23:35, Romain Guy romain...@google.com wrote:
 Cycleinterpolatordoes not exist. And it's not how you specify an
 animation'sinterpolatoranyway :)



 On Thu, May 14, 2009 at 2:34 PM, TjerkW tje...@gmail.com wrote:

  I specified an animation resource using xml:

  set xmlns:android=http://schemas.android.com/apk/res/android;
         alpha
                 android:fromAlpha=0.0
                 android:toAlpha=1.0
                 android:duration=5000
                 android:fillAfter=true /
    CycleInterpolator cycles=2/
  /set

  Exactly as explained here:
 http://developer.android.com/guide/topics/resources/available-resourc...

  What am i doing wrong here?
  I am getting this Exception:

  05-14 21:19:57.081: ERROR/AndroidRuntime(843): Caused by:
  java.lang.RuntimeException: Unknown animation name: CycleInterpolator
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.view.animation.AnimationUtils.createAnimationFromXml
  (AnimationUtils.java:117)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.view.animation.AnimationUtils.createAnimationFromXml
  (AnimationUtils.java:107)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.view.animation.AnimationUtils.createAnimationFromXml
  (AnimationUtils.java:84)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.view.animation.AnimationUtils.loadAnimation
  (AnimationUtils.java:64)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  com.airattack.SplashScreen.onCreate(SplashScreen.java:28)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
  1123)
  05-14 21:19:57.081: ERROR/AndroidRuntime(843):     at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
  2231)

  (b.t.w i solved this by setting the inperpolator using javacode.. but
  thats not the most beautifull solution)

 --
 Romain Guy
 Android framework engineer
 romain...@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
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android 2d Shooter Game AirAttack Follow My Blog!

2009-05-16 Thread TjerkW

Nope

On 10 mei, 05:49, Vincent Chan venc...@gmail.com wrote:
 Open Source?

 Vincent Chan

 On Sun, May 10, 2009 at 03:06, TjerkW tje...@gmail.com wrote:

  Hello Everybody!

  For anyone that is interested in following the development of my
  Android Game: AirAttack,
  i have started a blog where you can follow the development:

 http://airattackandroid.wordpress.com

  So if you are interested, check it out!
  You can also follow me on twitter:
 http://www.twitter.com/tjerkw

  Greetings!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Removing the default interpolator for xml based animation effects for views

2009-05-16 Thread TjerkW

This problem is related to my problem:
http://groups.google.com/group/android-developers/browse_thread/thread/4b39da63e56fb7e8/d89d4ab8e4462f2f?lnk=gstq=interpolator#d89d4ab8e4462f2f

It seams that android:interpolator=@android:anim/
linear_interpolator  is not public...

On 22 apr, 14:35, quakeboy prasna...@gmail.com wrote:
 I just had to create a new object like

 LinearInterpolator linint = new LinearInterpolator();
 myanimation.setInterpolator(linint)

 On Apr 9, 7:33 pm, quakeboy prasna...@gmail.com wrote:

  When ever I try to animate a view using a simple xml based animation,
  it seems to have defaultinterpolatorset of some kind as the motion
  is not truly linear.

  Is there a way to set the default animationinterpolatorto linear and
  remove the lag in the start/end of the animation.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Animation Xml Resource and CycleInterpolator tag: FAIL

2009-05-16 Thread TjerkW

Thanks for the info,
figured it out myself by now :-)

Nice to see you working on android, i followed your weblog a time ago
(a year or so) about
Swing and cool UI stuff (i think you worked @ sun then)!

Greetings,
Tjerk


On 16 mei, 20:44, Romain Guy romain...@google.com wrote:
  Euhm.. Then tell me why this class exists:
 http://developer.android.com/reference/android/view/animation/CycleIn...

 The class exists yes, but not its equivalent XML tag.

  An i just follow the documentation for specifying interpolators:
 http://developer.android.com/guide/topics/resources/available-resourc...

 I just read this documentation, it's wrong and very outdated.

  However when searching the internet is also see the following naming:
  @android:anim/ease_in_interpolator

 This comes from a very old version of Android, *before* 1.0.

  By the way.. i want to use the linear interpolator in my xml like
  this:
  android:interpolator=@android:anim/linear_interpolator

 Please file a feature request athttp://b.android.com.

 --
 Romain Guy
 Android framework engineer
 romain...@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
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Animation Xml Resource and CycleInterpolator tag: FAIL

2009-05-14 Thread TjerkW

I specified an animation resource using xml:

set xmlns:android=http://schemas.android.com/apk/res/android;
alpha
android:fromAlpha=0.0
android:toAlpha=1.0
android:duration=5000
android:fillAfter=true /
   CycleInterpolator cycles=2/
/set

Exactly as explained here:
http://developer.android.com/guide/topics/resources/available-resources.html#animation

What am i doing wrong here?
I am getting this Exception:

05-14 21:19:57.081: ERROR/AndroidRuntime(843): Caused by:
java.lang.RuntimeException: Unknown animation name: CycleInterpolator
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.view.animation.AnimationUtils.createAnimationFromXml
(AnimationUtils.java:117)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.view.animation.AnimationUtils.createAnimationFromXml
(AnimationUtils.java:107)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.view.animation.AnimationUtils.createAnimationFromXml
(AnimationUtils.java:84)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.view.animation.AnimationUtils.loadAnimation
(AnimationUtils.java:64)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
com.airattack.SplashScreen.onCreate(SplashScreen.java:28)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
05-14 21:19:57.081: ERROR/AndroidRuntime(843): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)


(b.t.w i solved this by setting the inperpolator using javacode.. but
thats not the most beautifull solution)





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Android 2d Shooter Game AirAttack Follow My Blog!

2009-05-09 Thread TjerkW

Hello Everybody!

For anyone that is interested in following the development of my
Android Game: AirAttack,
i have started a blog where you can follow the development:

http://airattackandroid.wordpress.com

So if you are interested, check it out!
You can also follow me on twitter:
http://www.twitter.com/tjerkw

Greetings!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Events not catched on real device using Activity.dispatchEventType

2009-04-12 Thread TjerkW

Hello all!

I am creating a game in which the user can control a ship by
- Using DPAD
- Using touchscreen
- Using trackball
- And even using orientation events (roll pitch etc)


It all works on the emulator but when i open the game on a real device
then
the events (touch, trackball) do not work anymore.

I am catching evetns by overriding the dispatchEventType() methods.
This is the code in my Activity class that catches the events:


  public boolean dispatchKeyEvent(KeyEvent e) {
super.dispatchKeyEvent(e);
return controller.onKeyEvent(e.getKeyCode(), e);
}

public boolean dispatchTrackballEvent(MotionEvent e) {
if(settings[2] || settings[3]) {
return controller.onTrackballEvent(e);
} else {
return super.dispatchTrackballEvent(e);
}
}

public boolean dispatchTouchEvent(MotionEvent e) {
if(settings[1]) {
return controller.onTouchEvent(e);
} else {
return super.dispatchTouchEvent(e);
}
}

I think the dispatchKeyEvent(..) method works fine, but the other ones
do not work on a real device.
They work without problems on the emulator.

What am i doing wrong?
I really do not understand it.

Thanks in advance.

-
Tjerk Wolterink


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Track Ball Problem...

2009-03-31 Thread TjerkW

I think the only way is to extend dispatchTrackballEvent(MotionEvent
e)... there is not View.TrackballListener class
strange.

On 27 mrt, 16:13, TjerkW tje...@gmail.com wrote:
 How do you register an activity to get trackball events?

 On 25 mrt, 18:31, David Turner di...@android.com wrote:

  You need to register your activity to the system to tell it that you can
  handle trackball events directly. If you don't, then the system will emulate
  the events with key down/up events.
  I don't know the API to do that.

  By the way, you can press Delete to enable track-ball mode in the emulator
  (or even Ctrl-T to toggle between trackball and non-trackball modes). This
  should help you develop your app.

  (And I recommend to use a real trackball mouse attached to your machine to
  test that, it really feels better than using a mouse).

  On Wed, Mar 25, 2009 at 5:25 PM, ANKIT SOMANI 
  ankitsomani...@gmail.comwrote:

   Hi,

   I want to Develop a Game in which I want to move my object using Track
   Ball. for this i use onKeyDown() to up,down,left,right,fire movement in my
   class. Its working fine in Emulator on D-Pad., but when i install in 
   device
   trackball not working efficiently. on Printing LogCat it says that the
   OnKeyUp() is called automatically on each OnkeyDown().. which is right but
   when I have to use is for continously(Continous trackball right 
   pressing)..
   It failed.I even try OnTrackBallEvent(). OnKeyMultiple... but not 
   working..

   If any body can help that on continous treating of trackball,  please 
   help.

   Thanks in Advance.

   Regards
   ~Ankit Somani
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: App Idea: Very interesting, unique, and information efficient text-entry method -- (no keyboard(not even on screen KB))

2009-03-28 Thread TjerkW

I used dasher before, but it was not easy to input text. I prefer just
buttons.
My collegues and i thought of a new way of text input: not a full
qwerty keyboard,
but only 1/2 the buttons but on all buttons 2 characters. Then use T9
like /dasher like
language probability models to get the correct word.

On 8 feb, 22:00, bdb4269 bdb4...@gmail.com wrote:
 Someone on another forum, was thinking that dasher would not be able
 easily allow abbreviations and informal typing that is common with
 cell phone text entry.

 I made this video to demonstrate that dasher adapts to however you
 type, and how it can handle any kind of language or abbreviations with
 ease.

 I figured I would post this video here as well so people could see how
 easy it is.

 This is a quick vid I made just now, to show how dasher makes
 abbreviations easy.
 Better quality:http://screencast.com/t/ffXiC9q2
 Same video on youtube (lower 
 quality)http://www.youtube.com/watch?v=nZHB-FbSHJo

 On Feb 2, 1:54 pm, bdb4269 bdb4...@gmail.com wrote:

  (To see this message in a much better format -- follow this 
  link)http://androidcommunity.com/forums/showthread.php?p=133454

  I think someone should port Dasher to Android.

  Dasher is free software, that takes an extremely unique approach to
  achieve information efficient text entry. It allows lots of different
  input methods, and is very adaptable, and customizable.

  Here is a description from the Dasher Website.

  [quote]Dasher is an information-efficient text-entry interface, driven
  by natural continuous pointing gestures. Dasher is a competitive text-
  entry system wherever a full-size keyboard cannot be used - for
  example,

      * when operating a computer one-handed, byjoystick, touchscreen,
 trackball, or mouse;
      * when operating a computer with zero hands (i.e., by head-mouse
  or by eyetracker);
      * on a palmtop computer;
      * on a wearable computer.

  ...usinga mouse[/touchpad/trackball], experienced users can write at
  39 words per minute.
  [/quote]

  Quick video, just to show it workhttp://www.youtube.com/watch?v=0d6yIquOKQ0

  An hour long video, that goes into detail, as to how it works, all the
  different ways it can be 
  used.http://video.google.com/videoplay?docid=5078334075080674416ei=caEsSZ...

  Dasher on an IPAQhttp://www.youtube.com/watch?v=4jxhJjkwleofeature=related

  The Dasher Websitehttp://www.inference.phy.cam.ac.uk/dasher/

  And just want to point out, that Dasher already has support for all
  sorts of languages, so if someone ported Dasher to Android, it would
  give it another unique option for text input in all sorts of
  languages.

  Here is a link that shows the language files already available for
  Dasher.http://www.inference.phy.cam.ac.uk/dasher/download/alphabets/ALPHABET...

  EDIT: By No Keyboard I just mean that this method does not involve a
  KB of any kind I do NOT mean to imply that this is a total
  replacement for the physical keyboard.. rather I think of it as a
  one handed on-screen text entry method to be used when convenient
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Track Ball Problem...

2009-03-27 Thread TjerkW

How do you register an activity to get trackball events?

On 25 mrt, 18:31, David Turner di...@android.com wrote:
 You need to register your activity to the system to tell it that you can
 handle trackball events directly. If you don't, then the system will emulate
 the events with key down/up events.
 I don't know the API to do that.

 By the way, you can press Delete to enable track-ball mode in the emulator
 (or even Ctrl-T to toggle between trackball and non-trackball modes). This
 should help you develop your app.

 (And I recommend to use a real trackball mouse attached to your machine to
 test that, it really feels better than using a mouse).

 On Wed, Mar 25, 2009 at 5:25 PM, ANKIT SOMANI ankitsomani...@gmail.comwrote:

  Hi,

  I want to Develop a Game in which I want to move my object using Track
  Ball. for this i use onKeyDown() to up,down,left,right,fire movement in my
  class. Its working fine in Emulator on D-Pad., but when i install in device
  trackball not working efficiently. on Printing LogCat it says that the
  OnKeyUp() is called automatically on each OnkeyDown().. which is right but
  when I have to use is for continously(Continous trackball right pressing)..
  It failed.I even try OnTrackBallEvent(). OnKeyMultiple... but not working..

  If any body can help that on continous treating of trackball,  please help.

  Thanks in Advance.

  Regards
  ~Ankit Somani
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Testing Android Game on real device: please help

2009-03-17 Thread TjerkW

I cannot follow only 1 thread there, it is all-threads or threads with
a specific keyword.
What i want is to only follow certain threads..

(sorry to be so off-topic)

On 15 mrt, 17:46, Stoyan Damov stoyan.da...@gmail.com wrote:
 Go tohttp://groups.google.com/group/android-developers/subscribe?hl=en
 and edit your membership

 On Sun, Mar 15, 2009 at 5:13 PM,TjerkWtje...@gmail.com wrote:

  Ok both your email adresses are noted... but the game still needs some
  work,
  so if i think it can be tested youll get an .apk in your inbox! :-)

  Btw: how do you subscribe to a thread in order to get automatic emails
  here at google-groups?
  I can only subscribe by easing search-words.. or by getting an email
  once a day ...
  I only want to subscribe to this thread... how do i do that?

  On 13 mrt, 15:53, Andrea Fanfani a.fanf...@dynamicfun.com wrote:
  On Fri, Mar 13, 2009 at 06:40:52AM -0700,TjerkWwrote:

   Hello all,

   I am making an android game, but i do not have the money to buy a
   developer phone.
   The game is not finished but i should it is testable.. and if i dont
   test it know i may
   have a big problem later... it is playable though.

   Is there somebody who has a real device and wants to test the game for
   me,
   just starting it up and playing it a little bit is good enough.

   It's a 2d airplane shoot gane, much like the old raptor game.

   If someone is interested please reply, i will sent you
   the (singed) APK and with some things i want to test (using both the
   buttons as well as touch screen for gameplay).

   Could anybody help me out?

  hi, send me at andrea.fanfani(at)gmail.com

  I will try to take a look at the application.

  a.f.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Testing Android Game on real device: please help

2009-03-15 Thread TjerkW

Ok both your email adresses are noted... but the game still needs some
work,
so if i think it can be tested youll get an .apk in your inbox! :-)

Btw: how do you subscribe to a thread in order to get automatic emails
here at google-groups?
I can only subscribe by easing search-words.. or by getting an email
once a day ...
I only want to subscribe to this thread... how do i do that?



On 13 mrt, 15:53, Andrea Fanfani a.fanf...@dynamicfun.com wrote:
 On Fri, Mar 13, 2009 at 06:40:52AM -0700,TjerkWwrote:

  Hello all,

  I am making an android game, but i do not have the money to buy a
  developer phone.
  The game is not finished but i should it is testable.. and if i dont
  test it know i may
  have a big problem later... it is playable though.

  Is there somebody who has a real device and wants to test the game for
  me,
  just starting it up and playing it a little bit is good enough.

  It's a 2d airplane shoot gane, much like the old raptor game.

  If someone is interested please reply, i will sent you
  the (singed) APK and with some things i want to test (using both the
  buttons as well as touch screen for gameplay).

  Could anybody help me out?

 hi, send me at andrea.fanfani(at)gmail.com

 I will try to take a look at the application.

 a.f.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Testing Android Game on real device: please help

2009-03-13 Thread TjerkW

Hello all,

I am making an android game, but i do not have the money to buy a
developer phone.
The game is not finished but i should it is testable.. and if i dont
test it know i may
have a big problem later... it is playable though.

Is there somebody who has a real device and wants to test the game for
me,
just starting it up and playing it a little bit is good enough.

It's a 2d airplane shoot gane, much like the old raptor game.

If someone is interested please reply, i will sent you
the (singed) APK and with some things i want to test (using both the
buttons as well as touch screen for gameplay).

Could anybody help me out?

Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: sound effect using SoundPool

2009-03-12 Thread TjerkW

Is the API of the SoundPool the same in cupcake?
I hope so.


For all the people who need a reliable soundpool, i have made a class
that handles the details with soundpool and is easy to use:

import java.util.HashMap;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Vibrator;
import android.util.Log;

public class SoundEffects {
public boolean released=false;
protected Context context;
private SoundPool soundPool;
  private int volume;
  private HashMapInteger, Integer soundPoolMap;


protected SoundEffects(int size, Context context) {
this.context=context;
// keep maxStreams high, ugly hack because pre cupcake android 
could
deadlock
// with soundpool
soundPool=new SoundPool(size+20, AudioManager.STREAM_MUSIC, 40);
soundPoolMap = new HashMapInteger, Integer();
AudioManager mgr=(AudioManager)context.getSystemService
(Context.AUDIO_SERVICE);
volume=mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
}

/*
public boolean isLoaded() {
soundPool.
}
*/

public void addSound(int resid) {
int soundId=soundPool.load(context, resid, 1);
soundPoolMap.put(resid, soundId);
soundPool.setLoop(soundId, 1);
}

public void addLoopSound(int resid) {
int soundId=soundPool.load(context, resid, 1);
soundPoolMap.put(resid, soundId);
soundPool.setLoop(soundId, -1);
}

public void play(int resid) {
Log.i(SoundEffects, Playing: +resid);
int soundId=soundPoolMap.get(resid);
soundPool.setLoop(soundId, 1);
soundPool.play(soundId, volume, volume, 1, 0, 1f);
}

public void playLoop(int resid) {
int soundId=soundPoolMap.get(resid);
soundPool.setLoop(soundId, -1);
soundPool.play(soundId, volume, volume, 1, 0, 1f);;
}

public void stop(int resid) {
//soundPool.stop(resid);
// apperently a bug, workaround
int soundId=soundPoolMap.get(resid);
soundPool.setLoop(soundId, 0);
soundPool.setVolume(soundId, 0f, 0f);
}

public void release() {
released=true;
soundPool.release();
}
}




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: sound effect using SoundPool

2009-03-12 Thread TjerkW


By the way: try to use .ogg files, they are played better by android.

Also i had problems with playLoop(int resid),
sometimes the sample is looped, and sometimes it is not.

A possible usage of the SoundEffects class is by subclassing it.
The code from my example ( i am making a col game! :-) :


public class GameSounds extends SoundEffects {
private static GameSounds INSTANCE;

public static GameSounds getInstance(Context ctx) {
//return new GameSounds(ctx);
if(INSTANCE==null || INSTANCE.released)INSTANCE=new 
GameSounds(ctx);
return INSTANCE;
}

private GameSounds(Context context) {
super(17, context);

addSound(R.raw.engage);
addLoopSound(R.raw.alarm2);
addSound(R.raw.fire);
addSound(R.raw.explosion1);
addSound(R.raw.explosion2);
addSound(R.raw.smallexplosion);
addSound(R.raw.mediumexplosion);
addSound(R.raw.lasergun);
addLoopSound(R.raw.machinegun1);
//addSound(R.raw.);
addSound(R.raw.heal);
addSound(R.raw.enemydeath);
addSound(R.raw.bossdeath);
//addSound(R.raw.bigexplosion);
//addSound(R.raw.shortshoot1);
addSound(R.raw.shortshoot2);
//addSound(R.raw.gunload);
}

public void smallExplosion() {
play(R.raw.smallexplosion);
}

public void explosion() {
play(R.raw.mediumexplosion);
}

public void explosion2() {
play(R.raw.explosion2);
}

public void engage() {
play(R.raw.engage);
}

public void heal() {
play(R.raw.heal);
}

public void nextWave() {
play(R.raw.heal);
}

public void fireVoice() {
play(R.raw.fire);
}

public void fire() {
play(R.raw.smallexplosion);
}

public void fire1() {
//play(R.raw.shortshoot1);
}

public void fire2() {
//play(R.raw.shortshoot1);
}

public void startFire() {
playLoop(R.raw.machinegun1);
}

public void stopFire() {
stop(R.raw.machinegun1);
}

public void startAlarm() {
playLoop(R.raw.alarm2);
}

public void stopAlarm() {
stop(R.raw.alarm2);
}

public void gameover() {
play(R.raw.bossdeath);
}
}



On 12 mrt, 21:37, TjerkW tje...@gmail.com wrote:
 Is the API of theSoundPoolthe same in cupcake?
 I hope so.

 For all the people who need a reliablesoundpool, i have made a class
 that handles the details withsoundpooland is easy to use:

 import java.util.HashMap;
 import android.content.Context;
 import android.media.AudioManager;
 import android.media.SoundPool;
 import android.os.Vibrator;
 import android.util.Log;

 public class SoundEffects {
         public boolean released=false;
         protected Context context;
         privateSoundPoolsoundPool;
   private int volume;
   private HashMapInteger, Integer soundPoolMap;

         protected SoundEffects(int size, Context context) {
                 this.context=context;
                 // keep maxStreams high, ugly hack because pre cupcake 
 android could
 deadlock
                 // withsoundpool
                soundPool=newSoundPool(size+20, AudioManager.STREAM_MUSIC, 40);
                 soundPoolMap = new HashMapInteger, Integer();
                 AudioManager mgr=(AudioManager)context.getSystemService
 (Context.AUDIO_SERVICE);
                 volume=mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
         }

         /*
         public boolean isLoaded() {
                soundPool.
         }
         */

         public void addSound(int resid) {
                 int soundId=soundPool.load(context, resid, 1);
                 soundPoolMap.put(resid, soundId);
                soundPool.setLoop(soundId, 1);
         }

         public void addLoopSound(int resid) {
                 int soundId=soundPool.load(context, resid, 1);
                 soundPoolMap.put(resid, soundId);
                soundPool.setLoop(soundId, -1);
         }

         public void play(int resid) {
                 Log.i(SoundEffects, Playing: +resid);
                 int soundId=soundPoolMap.get(resid);
                soundPool.setLoop(soundId, 1);
                soundPool.play(soundId, volume, volume, 1, 0, 1f);
         }

         public void playLoop(int resid) {
                 int soundId=soundPoolMap.get(resid);
                soundPool.setLoop(soundId, -1);
                soundPool.play(soundId, volume, volume, 1, 0, 1f);;
         }

         public void stop(int

[android-developers] Re: Screen Orientation change performance Question

2009-03-10 Thread TjerkW

I do not want my view to rotate when the user opens the keyboard or
rotates the device (i make a game).
How do i disable this?
In the emulator it always rotates by hiting CTRL-F11

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Background music in application

2008-10-20 Thread TjerkW

On Oct 19, 2:09 pm, bins [EMAIL PROTECTED] wrote:
 hi...
 thanks for u r replay...

 Actually i am playing 2mb file ,,,which is have looping also.I am
 calling Media player Inside a thread,Actually i need play background
 music for my application,and it should not effect my application speed

Playing a file in the background needs resources (cpu cycles).
If you application is already using all the resources then the
background music WILL affect
your application speed.

By the way, i am also getting those error messages, i think
it has something to do with reading the file and sending it to
the audiobuffer. My emulator is rather slow, so maybe
my machine is not fast enough.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Emulator Performance VS Real Phone Performance

2008-10-15 Thread TjerkW

On 15 okt, 00:48, hackbod [EMAIL PROTECTED] wrote:
 The emulator in no way tries to emulate the performance
 characteristics of real hardware.

 For this and many other reasons, every developer should run their
 application on real hardware before considering it to be ready for for
 release to the public.


I do not have to money to buy a android phone.
I thought the emulator emulates a real phone, too bad.

 Re:

  I thought about decoupling the movement from the framerate (speed =
  pixels/second), but this
  requires the use for floats, which make the calculation rather slow.

 In a game you should never tie the speed of movement to the frame
 rate, because that will of course vary across different hardware.
 Even if we were doing a google phone and completely controlling the
 hardware, we'd want to release new hardware in the future that goes
 faster, and your game then wouldn't work well with it.


I understand that.

 Also there should be no reason to need floats to deal with this, you
 can use fixed point integers.

How should i do it.

Supposei have the following:
int BULLET_SPEED=30; // 30 pixels/second

// then on a frameDraw
long deltaT=thread.getFrameTime(); // the time it took to move to a
new frame, in millis
int movement=(BULLETSPEED*deltaT)/1000;   ///   v*t = d

The problem here is that movement is always zero because the devision
is done with 1000 (1 second).
So either i use this:

int movement=(int)((BULLETSPEED*deltaT)/(float)1000);

Which required FLOATING POINT calculation.

Or i make the bullet speed a float. But this also requires floating
point calculation.

So how is it done, without the need of floating points?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Does SoundPool work or has anyone successfully used it?

2008-10-14 Thread TjerkW

I also wanted to use the soundpool, but lack of documentation made it
impossible to use.
I tried it they way i would think it would work, but it didn't.

I am using mediaplayers now,  i cannot play the same sound multiple
times concurrently, Too bad.

On 12 okt, 19:32, Robert Green [EMAIL PROTECTED] wrote:
 I have a few more comments on this class.

 1)  Is it going to be officially supported?

 2)  Here are some problems I've found with it and workarounds I used:

 Bug #1) Looping an mp3 crashes around the 8th loop but looping waves
 seems to work fine.
 Bug #2) SoundPool.stop(streamId) immediately crashes the app.
 Bug #3) setRate() with a rate over 1.5 either doesn't work or also
 crashes the VM with no exception.

 My new workaround for lack of stop():

 to stop a stream, call setLoop(streamId, 0) then setVolume(streamId,
 0f, 0f). This will stop a loop after it's done but drop the volume so
 it seems to the user to have quit right then. After that, you don't
 need to call stop() because the stream will clean itself up from the
 loop stopping. This worked for me.

 Even if they haven't readied it for public use, it's the only suitable
 API forsoundin games. I looked into using MediaPlayers but if you
 have more than a couple of sounds and you need to be able to play the
 samesounda few times concurrently, it's just not a feasible
 solution.

 I'm really surprised that there is no access to the audio buffer. How
 are we supposed to write dynamic audio generation apps?

 Androidreally needs 2 things to be competitive with the audio side:

 1) Public access to the media decoders (so a dev can decode an mp3
 into raw)
 2) Public access to asoundstream output buffer (so a dev can pipe in
 rawsounddata)

 On Oct 11, 5:30 pm, Robert Green [EMAIL PROTECTED] wrote:

  Problem solved.  Here's how I did it:

  This only loads onesoundbut you can load as many as you want. I have
  an mp3 in my res/raw directory called explosion.mp3.

  Java:

            public static final int SOUND_EXPLOSION = 1;
            public static final int SOUND_YOU_WIN = 2;
            public static final int SOUND_YOU_LOSE = 3;

            private SoundPool soundPool;
            private HashMapInteger, Integer soundPoolMap;

            private void initSounds() {
                 soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC,
  100);
                 soundPoolMap = new HashMapInteger, Integer();
                 soundPoolMap.put(SOUND_EXPLOSION,
  soundPool.load(getContext(), R.raw.explosion, 1));
            }

            public void playSound(intsound) {
                 AudioManager mgr = (AudioManager)
  getContext().getSystemService(Context.AUDIO_SERVICE);
                 int streamVolume =
  mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
                 soundPool.play(soundPoolMap.get(sound), streamVolume,
  streamVolume, 1, 0, 1f);
            }

            public void update() {
                 if (isExploding()) {
                       playSound(SOUND_EXPLOSION);
                 }
            }

  On Oct 11, 12:11 pm, Robert Green [EMAIL PROTECTED] wrote:

   I'm addingsoundinto my game now and need the ability to havesound
   effects concurrent (like 2 of the same explosion playing at the same
   time, etc) so using the MediaPlayer is less than optimal for me. I was
   thinking of just adding a traditionalsoundupdate into the main loop
   which would probably work and isn't _that_ hard to write but I don't
   think I have access to the decoder andsoundbuffer.

   I found a class called SoundPool that appears to be suited for exactly
   what I'm trying to do however the documentation is very weak 
   -http://code.google.com/android/reference/android/media/SoundPool.html

   Has anyone used this with success? If so, could I see a little code
   snippet?

   I tried this:
   Java:

             private void initSounds() {
                  // 4 streams
                  // stream type 3 is music
                  soundPool = new SoundPool(4, 3, 100);
                  int explosionSound = soundPool.load(getContext(),
   R.raw.explosion, 1);
                  soundPool.play(explosionSound, 100, 100, 1, 0, 1);
             }

   but it didn't appear to do anything. I didn't get errors but I also
   heard nosound. Perhaps I need to configure something for the emulator
   to work like that?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Playing Sounds, What is the fastest? PCM MP3?

2008-10-14 Thread TjerkW

I am playing sounds from resources using the MediaPlayer,
the point is that multiple sounds play simultanously.

This decreases the performance of the game,
i used stereo 44100 hz mp3 sound.

Now i changed it to WAV PCM 33800 (i think) mono.
However this  increases performance only a little (on the emulator).

So what sounds-formats/codecs should i use.
And what is the best way (performance wise) to play a sound?

(PS its a game)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Emulator Performance VS Real Phone Performance

2008-10-14 Thread TjerkW

I am writing a game, the movement in that game is based on the
framerate. (speed = pixels/frame)
The framerate depends on the speed of the device.

I have the feeling that my emulator is running relatively slow
compareed to a real phone,
( for example sound stutters).
I am getting max 30 fps in a simple 2d game.

How do i know wether the performance of the emulator really emulates
the performance of a real phone?
Or is it phone dependand? ( cause android is decoupled from a real
phone )
?

I thought about decoupling the movement from the framerate (speed =
pixels/second), but this
requires the use for floats, which make the calculation rather slow.

Thats why i am asking this question..

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---