0

当我删除 onResume() 方法时,程序运行良好,但是当我将其留在程序中时,程序正常启动,音乐播放,但屏幕上没有显示任何内容,然后当我尝试退出时,它冻结并需要一分钟电话从被冻结中走出来。这个 onResume() 方法有什么问题?您需要查看我的所有代码吗?为什么会发生这种情况?

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    int spot = settings.getInt("point", 0);
    try {
        music.get(track).prepare();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    music.get(track).seekTo(spot);
    music.get(track).start();
}

这是 onCreate()

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    song0 = MediaPlayer
            .create(TheParty0Activity.this, R.raw.blacksunempire);
    song1 = MediaPlayer.create(TheParty0Activity.this, R.raw.blueskies);
    song2 = MediaPlayer.create(TheParty0Activity.this, R.raw.fuckingnoise);

    music.add(song0);
    music.add(song1);
    music.add(song2);

    music.get(track).start();

    // box = (TextView) findViewById(R.id.editText1);
    // play = (Button) findViewById(R.id.button0);
    next = (Button) findViewById(R.id.button1);
    // extra = (Button) findViewById(R.id.button2);

    next.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            music.get(track).stop();
            track++;
            if (track == 3) {
                for (int i = 0; i < 3; i++) {
                    try {
                        music.get(i).prepare();
                    } catch (IllegalStateException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    music.get(i).seekTo(0);
                }
                track = 0;
            }
            music.get(track).start();
        }
    });
    extra.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            Intent ourIntent = new Intent(TheParty0Activity.this, Sam.class);
            startActivity(ourIntent);
        }
    });


}
4

1 回答 1

0

没关系,这些方法都不是问题

于 2012-08-22T06:03:15.527 回答