cr5315
Android Enthusiast
I've basically finished my app, when I realized that it would run in the background forever unless killed by the Android system or one of those app killing apps. I tried onStop and onPause with finish() after them, and when I tried that, I got the "Application stopped unexpectedly" error. Then today, when I tried something else, rather than that, the app just closed right away without me pressing home or back.
Here's my code without onStop/onPause
Here's my code without onStop/onPause
Code:
package com.bb.abbi;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class AbbiActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.choose);
mp.start();
Button one = (Button) findViewById(R.id.button01);
one.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.love);
mp.start();
}})
;
}
}