我制作了一个简单的应用程序,当按下按钮时会播放声音并记录它被点击的次数。它在模拟器上工作正常,但在实际设备上,按下按钮时它会崩溃。
代码:
package com.ian.counter;
import android.app.Activity;
import android.view.View;
import android.widget.TextView;
import android.os.Bundle;
import android.widget.Toast;
import android.media.MediaPlayer;
public class CounterActivity extends Activity {
/** Called when the activity is first created. */
TextView textView1;
//MediaPlayer ding;
int count = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView1 = (TextView) this.findViewById(R.id.textView1);
textView1.setText(Integer.toString(count));
//ding = MediaPlayer.create(this, R.raw.ding);
}
public void Count(View view){
count ++;
textView1.setText(Integer.toString(count));
//ding.start();
}
}
有人知道为什么它可以在模拟器上运行但不能在设备上运行吗?