Hi all,
I have an android main activity which starts a service (class
extending service).
The services onStart creates a Mediaplayer and starts playing an mp3
file.
Then when you click something in my main layout (from the main
activity), I call startActivity to fire another screen. I would assume
my music background service keeps running, however it finishes. How
can I achieve my goal then?
Thanks,
Thomas
Snippet from main class
+++++++++++++++++++++++++++++++++++++++++++++++++
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.titlescreen);
try {
Intent svc = new Intent(this.getBaseContext(),
BackgroundSoundService.class);
startService(svc);
}
catch (Exception e) {
//Log.e(Global.TAG, "ui creation problem", e);
}
btnParty = (ImageButton) findViewById(R.id.ImageButton01);
btnParty.setOnClickListener(new ImageButton.OnClickListener()
{
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(),
PartyScreen1.class);
//startActivityForResult(myIntent, 0);
startActivity(myIntent);
}
});
+++++++++++++++++++++++++++++++++++++++++++++++++
Snippet from Service
+++++++++++++++++++++++++++++++++++++++++++++++++
public class BackgroundSoundService extends Service {
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
// TODO
MediaPlayer mp = MediaPlayer.create(getBaseContext(),
R.raw.olddevil);
mp.start();
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onDestroy() {
System.out.println("I got destroyed now :(");
}
@Override
public void onLowMemory() {
System.out.println("I am on low memory :(");
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---