我尝试移至另一个活动并同时关闭音乐,然后将其重置为开始位置,但是当我尝试执行该操作时,该应用程序便停止了。这是我的代码:
case R.id.nextGLY:
if (shuffleState == SHUFFLE_CHECKED)
{
song.release();
song = "null";
Random songNumber = new Random();
int nextSong = songNumber.nextInt(3);
switch (nextSong)
{
case 0:
startActivity(new Intent(SongGLY.this,SongSOY.class));
break;
case 1:
startActivity(new Intent(SongGLY.this,SongADCG.class));
break;
case 2:
startActivity(new Intent(SongGLY.this,SongC.class));
break;
}
}
else
{
startActivity(new Intent(SongGLY.this,SongSOY.class));
}
break;
我还希望该应用程序移动到另一首歌曲布局,当音乐结束时可以调用活动,但我无法弄清楚。我有这样的东西
if (song.getCurrentPosition() == lengthSong && loopingState == REPEAT_UNCHECKED)
{
startActivity(new Intent(SongGLY.this,SongSOY.class));
}
我需要将其放入线程中吗? 谢谢。