Honeycomb full screen game issues

by Leigh McRae » Thu, 19 May 2011 06:26:57 GMT

Sponsored Links

My game isn't handling Honeycomb correctly it seems.  I get the
DisplayMetrics in Activity.onCreate and setup my game expecting to be
able to use the full screen.  So I'm guessing that I need to go
through the process of creating a View and getting it's size in order
for it to work on Honeycomb.

The problem is, from what I'm seeing, is that the view isn't created
and fully measured until sometime after Activity.onResume.  The first
shot I get at it with valid dimensions is in my
SurfaceHolder.Callback.  Right now my game is setup to pretty much
have a one to one mapping of the Android Activity lifecycle and I need
my screen size pretty early on.  Is there anyway around this?  All I
can think to do is not create my app until the first time the surface
is created.


Re: Honeycomb full screen game issues

by Dianne Hackborn » Thu, 19 May 2011 07:51:17 GMT

 Yes the actual dimensions available to your app are not known until
View.onSizeCreated() or SurfaceHolder.Callback.surfaceCreated().

On Wed, May 18, 2011 at 3:26 PM, Leigh McRae <leigh.mc...@lonedwarfgames.com

Dianne Hackborn
Android framework engineer

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


Sponsored Links

Other Threads

1. Application crashes on Samgsung Moment

Hi All,
Has anyone had any problems with their applications crashing on the
Samsung Moment?

I have a customer who is reporting that my application crashes
on their Samsung Moment when installing and crashes when they try to
run app.
Even posted very negative comments and ratings because of issues

Neither I nor any of the 5 testers I depend on can reproduce the
I've tested my app on the simulator with 1.6 - 2.1 all res/density and
no problems.
The following devices were used for testing:

- HTC Magic
- HTC Hero
- Milestone,
- Nexus1,
- Motorola Droid
- G1
- MyTouch

The customer's firmware is Android 2.1.
I've tested my app on the simulator with 1.6 - 2.1 and no problems.

At this stage I'm stumped!
I'm not sure what else to do!

I have refunded the customer's money and exchanged several emails
trying to deduce the root of the issues.
The customer is understandably frustrated and upset.

I have sold over 200copies of my app on Market & elsewhere and this is
the first customer
who has reported any such problems.

Any advice on this would be appreciated.


the app in question is MathPac, a mathematics utility package. I also
have StatsPac listed and they were developed together so the issue may
extend to StatsPac as well even though no one has yet reported it.


2. Occasional opengl texture corruption.. sometimes works, sometimes doesn't

Hi all,

I'm having a pickle of a problem with some fairly simple opengl texture

I have a situation where I want to tile a texture across a surface larger
than the texture bitmap.. pretty standard stuff.  I have a simple triangle
"grid" that I use to setup the vertices etc (code pasted below).  The
problem is that the code works perfectly for some textures, and weirdly for
others.  Interestingly it behaves differently for the same bitmap in
different cases.

When the texture is corrupt, it looks like my vertices have been setup in
the wrong order or something because the triangle pairs look backwards, and
distorted.. see the two images below:

Texture OK:


Texture Corrupt


You can see in the corrupt version that the individual "stones" are split
diagonally and sort of distorted into a rhomboid shape.  Plus there's some
funky pixels along the bottom.

The only difference in these two cases is the dimensions of the surface onto
which the texture is mapped.

I also get the same problem on "some" textures which are mapping to surfaces
of a size identical to the size of the bitmap (i.e not tiling).. but again,
it works for some and not others.  It works all the time on the emulator,
but fails on a real device (HTC Desire in my case).

Here's the code I'm using (paraphrased):



// Load bitmap

Bitmap bitmap = null;
InputStream is = context.getResources().openRawResource(resourceId);
try {

// sBitmapOptions is just sBitmapOptions.inPreferredConfig =

bitmap = BitmapFactory.decodeStream(is, null, sBitmapOptions);
finally {


// Bind texture

// mTextureNameWorkspace is just an int array
// mTextureHash is a simple data structure holding texture refs

gl.glGenTextures(mTextureHash.size(), mTextureNameWorkspace, 0);

// textureName is just an int taken from the mTextureNameWorkspace above

gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,

GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);


// Setup gl


gl.glClearColor(0,0,0, 1);




// create the texture grid

// width & height are the dimensions of the sprite (as floats).. not the

float hW = width / 2.0f;
float hH = height / 2.0f;

// Use the dims to create the vertices.
vertices = new float[] {
      -hW,  hH, 0.0f,  // 0, Top Left
      -hW, -hH, 0.0f,  // 1, Bottom Left
       hW, -hH, 0.0f,  // 2, Bottom Right
       hW,  hH, 0.0f,  // 3, Top Right

// a float is 4 bytes, therefore we multiply the number if
// vertices with 4.
ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
vertexBuffer = vbb.asFloatBuffer();

// short is 2 bytes, therefore we multiply the number if
// vertices with 2.
ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
indexBuffer = ibb.asShortBuffer();

// textureWidth and textureHeight are basically the dimensions of the bitmap
(as floats)

if(textureWidth > 0) {

 // create the texture buffer.

// We need to tile the texture so we dont stretch the bitmap
 float u = width / textureWidth;
float v = height / textureHeight;

texVerts = new float[] {
0.0f,0.0f, // 0, Top Left
 0.0f,v,   // 1, Bottom Left
u,v,   // 2, Bottom Right
 u,0.0f,   // 3, Top Right

ByteBuffer tbb = ByteBuffer.allocateDirect(texVerts.length * 4);
 textureBuffer = tbb.asFloatBuffer();

// Do the draw

// Counter-clockwise winding.

// Enable face culling.

// What faces to remove with the face culling.

// Specifies the location and data format of an array of vertex
// coordinates to use when rendering.
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);

gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT,

// Disable face culling.

// Tear down.. blah blah...


Sorry for pasting so much code.. but just not sure where the problem is...
 Am I winding up the triangles wrongly or something?

Any help GREATLY appreciated.




3. private file last modified date

4. BroadcastReceiver::onReceive Question

5. custom listview add button above listeview

6. How to cite/reference free images

7. SUGGESTION: use a different icon for calls that don't connect due to busy signal