i am trying to insert a audio file into the application which is not showing any kind of error but while am running the program then it is showing some kind of exception that to force close kind of dialog box and here is my code
This is my first activity where am trying to invoke the button into the second activity playing the audio file.
public class Audio extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b2=(Button)findViewById(R.id.b1);
b2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i1 =new Intent(Audio.this,Audio1.class);
startActivity(i1);
}
});
}
}
public class Audio1 extends Activity {
private MediaPlayer eMediaPlayer= new MediaPlayer();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.audio);
eMediaPlayer=MediaPlayer.create(this, R.raw.ab);
eMediaPlayer.start();
}
}
- audio is my xml file which is empty presently
- R.raw.ab is the resource file which is 830kb audio file
you should call
before