I created an android app that has a streaming audio. I need to create an audio player on the lock screen to continue running in the background. What is the best option for this? Should I create a widget?
For android 4.2 and above you can use the official lock screen widget which is documented over here - App Widget
And there is already a thread present which contains some discussion if the version is below 4.2 :
Android Lock Screen Widget
Related
I want to force a widget to appear on the lock screen in Android.
Any ideas or code examples?
Thanks in advance.
First, the standard Android lockscreen framework only supports app widgets from Android 4.1 through 4.4, which is a steadily shrinking portion of the Android device ecosystem.
Second, there is no programmatic means, in standard Android, to force the user to add an app widget to the home screen or to the lockscreen.
I'm developing an app for Android that streams content to a Chromecast device.
I did not find the documentation about the way to change the volume of the remote media player when the app is in the background.
Look at the method setUpRemoteControl() in VideoCastManager class, in CCL; it is mostly done there.
It was enough to call:
mediaRouter.addRemoteControlClient(mRemoteControlClient);
where:
mMediaRouter = MediaRouter.getInstance(context);
Per the CastCompanionLibrary detailed documentation:
CCL can provide default lock screen controllers based on the RemoteControlClient. If desired,
this feature needs to be enabled at the initialization time of the VideoCastManager. When this
feature is enabled, a Play/Pause button will be shown on Android devices running Jelly Bean or
above. On KitKat devices, the layout of the lock screen controllers is different and uses a
full-screen album art while on Jelly Bean it is a small version of the album art.
In addition, when this feature is enabled, CCL provides the ability for users to control the Cast
device’s system’s volume even if the application is in the background. On KitKat devices, it provides that capability even if the screen is off
For the CastVideos-android sample, they do that in CastApplication immediately after intialization of VideoCastManager:
mCastMgr.enableFeatures(
VideoCastManager.FEATURE_NOTIFICATION |
VideoCastManager.FEATURE_LOCKSCREEN |
VideoCastManager.FEATURE_DEBUGGING);
Google Play Music app adds a special lock-screen widget dynamically when playing music (on Jelly Bean), and removes it after exit. This widget cannot be removed manually by dragging, and when I unlock my phone, it is always the top one besides other lock-screen widget.
How to implement this special dynamic lock-screen widget? I can only find documents about regular lock-screen widget, but not for this.
I was looking for the same thing and found out this is done by using the RemoteControlClient, check #CommonsWare answer here What is RemoteControlClient in Android 4.0?
I read a lot of threads about lock screen widget and I can't understand whether its possible to build lock screen widget for Android version less than 4.2?
I have a music app and I want a widget in lock screen that can play, pause, play next and last song, similar to iPhone lock screen when iPod playing and same as music player for Android.
If it's not possible for Android 2.1 - 4.1 then why can the native music player in android 2.3.3 on Samsung Galaxy S2 do it?
It seems like duplicate question. Please check my answer here for the lockScreen control you required.
Answer: Media Control on Lock Screen like Google Play Music in android?
I am implementing a Music player Application. for that Application i want to implement a playback widget that stays on their lock screens and allows them to interact with the app.
i have found that it is possible in Android 4.2 Api. but some of the music player application can provide this feature in above Android 3.0
So that i have searched a lots of thing to implementing an screen lock widget that support from Android 3.0, but i can't found anything about it.
Any one have a solution or step, how to making lock screen widget that support from Android 3.0. ?
waiting for you reply.
Thanks in Advance.
You can make it into an activity instead of a widget and use certain flags such as FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD to achieve this I think. This thread will help you:
Android Lock Screen Widget