0

This is more of a curiosity than anything else but it would be good to get some feedback from everyone on possible problems and solutions etc.

Is it possible to use one "host" activity and use that activity to display 3-4 different activities?

I already use tab host in my app and this doesn't seem to fit my needs in regard to the menu idea, ill explain what I'm trying to do as it may help.

Im trying to find a nice clean solution to playing background music, but this could be applied to other functions as well, but essentially, after the splash screen i would like a "host" activity to load first and in that activity, load up a menu activity, when the use presses a button the menu activity, i would like the next activity to load up still inside the "host" activity.

I'm hoping this would make playing music etc as clean as possible and with as little extra coding as possible.

Is this idea possible? would it be beneficial? what would be the best way to accomplish this?

Like i said this is more of a curiousity than a "gimme code to do it", I can work that out once i know the direction to head in & if its possible, I mainly want this for b/g music at the moment but im sure this could be applied other functions.

Thanks for looking, reading giving your thoughts :)

phil

  • 2
    Playing background music is best implemented with a Service. You can then control that Service from any of your Activities – Alexander Kulyakhtin Oct 07 '14 at 11:06
  • You might have interest in this: http://stackoverflow.com/questions/16336960/android-playing-music-in-background – jbutler483 Oct 07 '14 at 11:09
  • thanks for your quick reply, I can see that being the option im going with, but still, do you think it is possible to use a host activity as container for other activities? – user2886912 Oct 07 '14 at 11:09
  • 2
    `i would like the next activity to load up still inside the "host" activity.` That's what **Fragments** are there for. `1 Activity, many Fragments` inside it, alternatively and/or concurrently shown. – Phantômaxx Oct 07 '14 at 11:11
  • 1
    your idea fits best with Fragments: You can well load a Menu Fragment, then when the user selects an option, ie. show photos, load photos fragment anywhere in the screen. Read about Fragments, they have the lifecycle and structure of activities. – rupps Oct 07 '14 at 11:12
  • i completely forgot about fragments! thanks guys for your help. much appreciated :) – user2886912 Oct 07 '14 at 11:27

0 Answers0