0

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();

}
4

1 回答 1

0

发现它没关系!这是可能对其他人有用的答案。我把我所有的图形都放在了一个 touchlistener 事件上,一切都很好。

于 2013-05-17T23:21:48.113 回答