android锁屏流程_Android的锁屏和键盘控制

本文探讨了在Android平台上开发媒体播放器应用的过程,重点讨论了服务活动的作用及其优势,并介绍了如何集成标准锁屏控制及利用键盘快捷键。通过参考官方示例和开源项目,帮助开发者更好地理解媒体播放器的设计和实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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!

解决方案

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值