Android Lock Screen and Keyboard Controls

亡梦爱人 提交于 2019-12-09 23:37:31

问题


I am part way through writing a media player app for Android. It's all going really well so far, however I am now reaching the difficult stage!

I have two questions. Do i need to implement a service activity? As I understand it, this is required to allow the app to continue working in the background. However, mine is working fine while I move to other programs on the tablet, and returns to the app without problems. Can someone please explain what the advantages are of services?

Secondly, I would like to integrate the media player with the standard lock screen controls in ICS, and also make it take advantage of tablets (such as the asus transformer) that have keyboard play/pause skip controls. I would appreciate it if someone could point me in the right direction to get me started. From my googling it would seem that BroadcastReciever is needed, or perhaps RemoteControlClient, but I've no idea where to start!

I have a main activity with actionbar tabs, which contain a music player fragment and soon a video player fragment.

Do i need to create a layout specifically for the lock screen, or can i make use of standard API's?

Any help gratefully received!


回答1:


You should check out the Random Music Player sample that comes with android SDK samples. It gives you lock screen controls and bluetooth control ability on ICS devices & up. I've used it myself, it is excellent. Also, the UniversalMusicPlayer sample on Github: https://github.com/googlesamples/android-UniversalMusicPlayer

Sample code can be found online too.

Igor



来源:https://stackoverflow.com/questions/11441626/android-lock-screen-and-keyboard-controls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!