Fast screen update

by qute » Tue, 22 Jun 2010 04:27:07 GMT

Sponsored Links

I'm new to this android development.
I've read a lot on the net how to do it, but I can't get the speed I

In init:
bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);

my onDraw method:
protected void onDraw(Canvas canvas) {

for (int j = 0; j < HEIGHT-2; j++) {
int heat = 0;
for (int i = 0; i < WIDTH; i++) {
heat = firebuf[j][i];
bitmap.setPixel(i, j, palbuf[heat]);

canvas.drawBitmap(bitmap, 0, 0, null);

// refresh the canvas

Is this the way to do it?
I come from the PC world, where I would have 2 buffers directly to the
gfx card. Write in one while the other is shown and then switch.
Couldn't find out how to do it on the android.


Fast screen update

by Miguel Morales » Tue, 22 Jun 2010 04:44:28 GMT

 Well, it looks like you're setting every pixel on the bitmap on every frame.
Android is not a PC, it's equivalent to a 10-15 year old pc, you'll
have to optimize your code.

You can try drawing directly to the canvas, instead of drawing to a
bitmap, and then drawing that bitmap onto the canvas.
Watch this: 
and then download things like this: #trunk/SpriteMethodTest
and this to see how it's done in production:  (it's an open source 2d game)


Sponsored Links

Other Threads

1. Does Android Messaging support EMS ?

Hi All :
     I'm studying Android and will start to develop some message
related AP after I familiar with Android , but when I play G1, I don't
know how to send a EMS , I do read 3GPP TS 23.040 and really
understand about SMS and EMS but still don't know how to send a EMS to
other MS , Does that mean Android phone don't support EMS ?  Your
suggestion will be appreciated.


2. Question for SDK developers - behavior of setFeatureInt

Hello SDK developers

I finally did get a reply for the problem below and I am being told

The problem is that the only Window implementation (PhoneWindow) uses
a LayoutInflater in its setFeatureInt method and instantiates the new
layout with inflate and attachToRoot=true. Consequently, when you call
setFeatureInt, the new layouts are not replaced but attached to the
internal title container and thus drawn on top of each other.

You can workaround this by using the a helper method instead of
setFeatureInt. The helper simply removes all views from the internal
title container before the new custom title feature is set

I did not find this documented in any of the javadocs or in any
references. Is setFeatureInt intended to behave like this?

This is the method I am using in order to remove all views from the
title. It works fine. Can anyone please confirm if this is the correct
way to remove views from the title or an undesirable hack likely to
change in the future updates. Thanks a lot.

private void setCustomTitle(int value) {
    try {
        // retrieve value for
        int titleContainerId = (Integer) Class.forName(

        // remove all views from titleContainer
        ((ViewGroup) getWindow().findViewById

        // add new custom title view
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, value);

    } catch(Exception ex) {}


3. can anyone post me to an example of using ACTION_TIME_CHANGED or ACTION_DATE_CHANGED

4. GeoCoder is not working in SDK 1.5

5. Get current activity from Service

6. Having a lot of problems finding the documentation (e.g. about sendevent)

7. how display text and images in single view