Question

Hi im trying to build an app which turn screen to some thing like flash lights or police siren .tested on galaxy gio with 2.3 android on it .on 2.3 + devices it stucks on first color. the error on logcat is skipped frames too much work for an activity ! ive tried to reduce the delay but it wont work.it only working on 4.0 + android version what should i do ?

public class MainActivity extends Activity {

RelativeLayout soli;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //full screeen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //full screen
    setContentView(R.layout.activity_main);
    //brightness full
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 100 / 100.0f;
    //brightness full
    soli = (RelativeLayout) findViewById(R.id.soli);

}
public void soheil(){


    final RelativeLayout soli = ((RelativeLayout) findViewById(R.id.soli));
    ColorDrawable f = new ColorDrawable(0xff00ff00);
    ColorDrawable f2 = new ColorDrawable(0xffff0000);
    ColorDrawable f3 = new ColorDrawable(0xff0000ff);
    ColorDrawable f4 = new ColorDrawable(0xff0000ff);

    AnimationDrawable a = new AnimationDrawable();
    int DELAY=1500;
    a.addFrame(f, DELAY);
    a.addFrame(f2, DELAY);
    a.addFrame(f3, DELAY);
    a.addFrame(f4, DELAY);
    a.setOneShot(false);

    soli.setBackgroundDrawable(a); //  is deprecated  API 16
    // soli.setBackground(a); //  API 16
    a.start();




}
@Override
protected void onStart() {
super.onStart();soheil();

}
@Override
protected void onDestroy() {
super.onDestroy();

}
@Override
protected void onResume() {
super.onResume();

}
@Override
protected void onPause() {
super.onDestroy();

}
@Override
protected void onStop() {
super.onDestroy();

}
Was it helpful?

Solution

Found It never mind ! this is the answer maybe useful to others . i put all my graphics on a touchlistener event and everything is going fine .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top