views:

67

answers:

2

Hi there,

I have an interesting problem and I was looking for a solution; Hoping that someone here can help me out.

(I did read through related questions on this topic but they have solutions which are not relevant to my situation).

Details are:

I have two activities. One is a simple list view to list available audio tracks. Another is a complex audio toolbar with controls to play/pause, ffd, and rewing the currently playing audio.

The audio toolbar uses a wrapper class that wraps the Android MediaPlayer object and this wrapper class is a singleton object. Which means that I eventually wish to use the audio toolbar anywhere in my app and control the singleton instance of my MediaPlayer wrapper.

For this reason, I cannot have the audio toolbar and the audio listview in the same activity since I want the toolbar to be a seperate entity altogether that pops up whenever the user wants to control the music, without having to see the listview.

Now, since the user would pop up the toolbar from anywhere in the app, I would love to know of a way to combine the current activity and the toolbar activity into one screen.

I do know that one option available to me is dialogs. I was looking for a more elegant solution where I could have the audio toolbar pop up at the bottom of the screen the user is on, without exiting the activity he is currently doing.

Anyone know of a way to do this? I didn't come across anything for this in the docs but if someone does know, even pointing me to the correct docs would be extremely useful :)

Thanks!

+1  A: 

You want to implement an ActivityGroup. To embed the Activities, you would use the LocalActivityManager to start each activity, and grab the Activity's view and embed it into the layout/container that the ActivityGroup displays.

codelark
Thanks! This seems to be another way to do this and I'm going to look into it since it seems like it's something I should know :)
Siddharth Iyer
A: 

Another is a complex audio toolbar with controls to play/pause, ffd, and rewing the currently playing audio.

A toolbar should not be an activity. It should be a widget.

For this reason, I cannot have the audio toolbar and the audio listview in the same activity

Sure you can, by making it a widget.

Now, since the user would pop up the toolbar from anywhere in the app, I would love to know of a way to combine the current activity and the toolbar activity into one screen.

Step #1: Convert the "toolbar activity" into a widget

Step #2: Put the widget into the layout for your activity

I was looking for a more elegant solution where I could have the audio toolbar pop up at the bottom of the screen the user is on, without exiting the activity he is currently doing.

Step #1: Convert the "toolbar activity" into a widget.

Step #2: Put the widget into the layout for your activity, specifically in a RelativeLayout, with the toolbar anchored to the bottom of the RelativeLayout, initially set with visibility of GONE.

Step #3: Use a TranslateAnimation to display and hide the widget as needed, based on whatever trigger you were going to use.

See here for a sample application demonstrating this technique.

CommonsWare
Seems like this is what I intended to do.... thank you :) Will try this out
Siddharth Iyer