Thread issues

No replies
Seeme
Joined: 05/02/2010
User offline. Last seen 18 weeks 5 hours ago.

Hi in there, I'm new to android dev, and I want to make a simple game to start with.

When the main activity is created, it launches a thread that's supposed to update the view at a good rate. But whaterver I do, I can't go over 10fps. The rate is pretty constant (average is 10fps), which makes me think that I'm still within the UI thread...

I attached the main activity. If you have any clue that could help me to understand why i can't go over 10fps, please help me.. I consider my work is almost finished, and I'm stuck on performance issues for 3 days...

Thank you.
Seeme

Edit: can't attach java file, here it is:

package org.plissken.android.activities;

import java.util.Timer;
import java.util.TimerTask;

import org.plissken.android.GameView;
import org.plissken.android.crazy.CrazyView;

import android.app.Activity;
import android.os.Bundle;

public class Game extends Activity{
private GameView gv;
private Timer myTimer;

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

gv = new CrazyView(this);
setContentView(gv);

myTimer = new Timer("GolemTimer", false);

//setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

@Override
public void onPause(){
super.onPause();
myTimer.purge();
}

@Override
public void onStop(){
super.onStop();
finish();
}

@Override
public void onResume(){
super.onResume();
gv.reset();

myTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if(gv.isPlaying()){
gv.postInvalidate();
}
}
}, 0, 1);
}
}