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.
Related
I have an Android app which plays mp3 files. I have programmed its main functions like play/pause forward, backward buttons, manipulating by SeekBar, getting current position and so on. Now I want to make my app to continue playing even I closed my app. And when I close it, I want to appear thing like widget in status bar with basic actions (displaying app icon, track name, play/pause button). And also, I want to SeekBar work properly when I reopen my app. Can anyone help me. I'm beginner in Android Java, so it would be perfect if your answer contains steps. Thanks beforehand
I think this tutorial perfectly match your query
Android custom notification for music player Example
It think you need to read this articles:
1) https://developer.android.com/guide/components/services.html?hl=ru - this articles can help you to play music on background. It's very important component of youar app;
2) If you want to provide a widget - just see this article https://developer.android.com/guide/topics/appwidgets/index.html?hl=ru
3) If you want to show notification in status bar, see - https://developer.android.com/guide/topics/ui/notifiers/notifications.html
Also, you can find many iteresting solutions and lessons here - http://startandroid.ru/ru/uroki/vse-uroki-spiskom/164-urok-99-service-uvedomlenija-notifications.html
https://developer.android.com/training/managing-audio/index.html?hl=ru - an interesting article about music players by Google Android Developers
Best regards,
Skidan Oleg
I want to know if there is an easy way for someone with almost inexistent coding skills to create this simple app. The only thing this app will do is act like a browser for a specific site and it will allow playback EVEN when the screen is off or the user has pressed the home button. So if a youtube video starts playing, it will be keep playing in the background if for example the user goes to another app.
Thank you very much for you app!
I think the easier and the most user-friendly way to do this is by using a front-end framework like Bootstrap...
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.
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.
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!