在 Android 中创建屏幕保护程序
是否可以为Android(不是锁屏)编写屏幕保护程序?
我正在寻找有关屏幕保护程序编程的教程。当用户不执行任何操作时,屏幕保护程序将激活。如果用户触摸屏幕,屏幕保护程序就会消失。这可能吗?
Is it poosible to program a screensaver for a android (not lock screen)?
I am looking for a tutorial on programming a screen saver. The screen saver will activate as the user does nothing more. If the user touches the screen, the screensaver will disappear. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
BroadcastReceiver
在您的应用中接收ACTION_SCREEN_OFF
。在此 BroadcastReceiver 的onReceive
方法中,启动一个 Activity 作为屏幕保护程序< /code>。您可以为
触摸事件
注册一个侦听器,当此事件发生时,完成您的应用程序。You can receive
ACTION_SCREEN_OFF
in your App with aBroadcastReceiver
.In theonReceive
method of this BroadcastReceiver, start an activity as thescreensaver
.And you can register a listener fortouch events
and when this event occured,finish your App.我给出了屏幕保护程序的摘录:评论会解释它。
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
点 res=new Point(); getWindowManager().getDefaultDisplay().getSize(res);
要查看完整代码,请参阅此处:- 代码示例-屏幕保护程序-彩色点
I am giving an excerpt for screen-saver : Comments will explain it.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Point res=new Point(); getWindowManager().getDefaultDisplay().getSize(res);
To see full code see here:- Code-Example-Screen-Saver-Colorful-Dots
Android 屏幕保护程序示例代码
在提出问题之前尝试先搜索答案
Android Screen Saver Sample Code
Try to search first for answers before asking for something