我在尝试强制关闭我的应用程序时遇到问题。下面是我在单击按钮时播放声音的代码。任何人都可以向我解释如何避免我遇到的问题吗?
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
public class Click extends Activity
{
MediaPlayer mp1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_click);
mp1 = MediaPlayer.create(this, R.raw.sound1);
final Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener((OnClickListener) this);
}
public void onClick(View v)
{
switch(v.getId())
{
case R.id.button1:
mp1.start();
break;
}
}
}