this is my first post on stack overflow so hoping you can help.
We are developing an Android App, that requires an audio player to always be available, no matter what activity you are on. Ideally, we want this to be a "pop up" style player that is accessible when you tap the screen or tab an always visible button (e.g. on the action bar). However, the player needs to overlay the activity you are on, and continue playing the audio as you move between activities and (ideally) multi task within your device.
I have looked into various options for this, and wonder if a service is the best way to go. The other option I am considering is a transarent activity. But I am open to suggestions!
Can anyone offer any guidance? Thanks in advance.
I think that service, playing the tracks is the best way to go.
For the player visual interface, you should have one view, which will be included wherever you need it.
When you open this view, you will get the information from the service (what track are you on, where exactly in the track) and initialize with those results.
At least this is my suggestion approach to the task. Good luck!
Have tried considering making it an android widget? It remains on the home screen and user can play music and get back to other tasks.
But not sure if it will meet your overlay criteria(Which I quite didn't understand.. :))
Check out Androids MediaPlayer-Class. This should prevent you with all nessesary playback functions. On how to create your player-controll-interface on Androids Action-Bar, check Googles Tutorial. But note that the ActionBar is available since Android 3.0, not in previous version!
Related
Currently I want to make an app but I don't know what this is called , I mean the android term for it, it's definately not a spinner, but more into the notifications.
I want to make an app that I can interact with just like the music bar here that can play music, stop next song , etc.
Can someone help me or tell me what that method is and where can I get some tutorials for it?
It doesn't seem to be an ongoing notification. (It's not being under the Ongoing tag being the clue, otherwise I could be sure that this was the case)
http://developer.android.com/reference/android/app/Notification.Builder.html#setOngoing%28boolean%29
It is probably a custom remote view
http://developer.android.com/reference/android/widget/RemoteViews.html
A quick google search will give you examples.
I'm currently using Appgyvers SteroidsJS (which is forks of Phonegap and Cordova), and would like to control the default music player from within the app on my Android (5.0.1). Simple things like play, stop, pause, next, and back.
I can't seem to find any direct way to accomplish this, or even a way to pop in to the Android API from Steroids/Phonegap. Does anyone have a solid method to do so or is it not possible? Thanks!
Nothing simple existed, so in the end I learnt how to write something myself. :)
https://github.com/dustinblackman/cordova-MusicControl/
Is there any way to programmatically pause an Android app in Phonegap? I would like to mimic the behavior that occurs when you hit the HOME button. I've already had to overwrite the back button handler using this, and while in most cases I want it to do my action, when in a particular state the user would expect the app to minimize, and I want to replicate this behavior.
Keep in mind, on Android this is not the same as closing the app. That is quite easy to do with device.exitApp(); but I would like it to remember its state and keep running in the background. Especially if there's still an asynchronous job being done in the background.
Is there a feature in Phonegap to achieve this?
Possible duplicate of Manually pause an application in Android Phonegap, but I couldn't find some of the tools the OP mentioned there such as navigator, so I was nervious to totally edit and rewrite their post
The simple answer appears to be: no.
However, for anyone else that comes down this path, its not impossible. It's just that there isn't a feature of Phonegap to do it for you.
The Android equivalent of "sleeping an app" is actually just opening another intent. Specifically, opening the "Home" intent would sleep the running app and bring you back to the home screen. But as far as I can tell from asking around and scoping the docs, Phonegap doesn't have a direct way of opening intents.
What you (supposedly) can do is one of two things:
This plugin is supposed to be promising
Call the Java code that does it yourself using the means described here
Mind you, as of right now I've decided to not go any further with this, so I make no promises about either of those means, having not attempted them myself.
I invite anyone else who decides to pursue this further to update their experience here.
I went through some posts, but most of them discuss placing a image or a string with information on it.
I however need to place button that manipulates some call features.
Is there a method to do that universally works throughout all android distributions?
(I thought to pop up custom screen with my button above usual screen. Is that good idea, or is there more straightforward way to achieve this?)
Thanks a lot
On stock devices there isn't going to be a legit way to put your own button "on" any portion of the Dialer application Activities (including incoming call screen). This kind of functionality would require the Dialer to explicitly provide an API for it. The stock system prevents applications in the background from placing their own clickable regions "on top of" whatever is currently in the foreground . (It's a good thing too, the bad reasons to do this far outweigh the legit ones.)
If you are wanting to do this you're going to have to look into building your own version of the OS that allows for it. OR potentially if you unlock your device enough to be able to install your own application that handles all of the functionality of the Dialer. Then you could provide an API for a third party application to do it(or just "bake in" your button to the Dialer) But I imagine that being able to get it all hooked up correctly to actually make your calls would be mighty difficult.
Actually, I found lots of answers for my questions but this time I am totally stuck.
My question is very easy. I am building a radio streaming application for .pls streams and when the user press the home button, I want my application to continue working. I think lots of you know ebuddy and Skype or the basic media players. They are putting themselves to notification bar and you can easily reach them from this place. I tried to create a notification for my app, but when I click the icon on the notification bar, I can't reach my app. It directly opens a new version of my app and I can't control the streaming, the initial working app is no longer existing.
You may want to read the descriptions for LaunchMode: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
You want to launch your Activity as singleInstance
Edit: maybe singleTask would be better.
This is the workflow you want to achieve:
All background work has to be done by a service. Implementing one is quite simple, almost as creating an activity.
There are many examples on how to do it:
http://developer.android.com/reference/android/app/Service.html
http://marakana.com/forums/android/examples/60.html
http://code.google.com/p/openmobster/wiki/AndroidService
You need the actual music playing part - or the part that should continue running in the background - to be a service, and the gui to be an activity. The notification you made should bring your activity gui to the front with a flag_activity_reorder_to_front.