Solution 1: use PowerManager and WakeLock
In AndroidManifest.xml:
<uses-permission android:name="android.permission.WAKE_LOCK" />
In your Activity:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
// in onResume() call
mWakeLock.acquire();
...
// in onPause() call
mWakeLock.release();
Solution 2: use the window flag FLAG_KEEP_SCREEN_ON
Put the following code in your Activity’s onCreate method:
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Set keep screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
Reference
分享到:
相关推荐
简单快捷。 这个小应用程序将允许您避免睡眠模式... 在 Android 上保留屏幕 在 apk 上保留屏幕 在 Google Play 上提供的应用程序上保留屏幕:https://play.google.com/store/apps/details?id=keepscreenon.awake.alive
在 Android 中,我们可以使用 WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON 来禁止屏幕休眠和锁屏。这个标志位可以使屏幕保持常亮,直到我们手动释放它。使用这个方法非常简单,我们只需要在程序中添加一行代码...
键身打卡App,基于原生Android、Java实现。页面简洁实用,功能齐全,代码注释多。 核心功能:登录注册、个人信息维护、系统设置、搜索、日历键身打卡、健身图文视频教程、收藏评论点赞购买教程、社区分享等。 适用...
在Android开发中,PopupWindow是一个非常实用的组件,它能够创建一种浮现在当前Activity之上的...通过阅读和理解这些代码,开发者可以更好地掌握如何在Android应用中创建类似Keep那样具有滑动交互效果的PopupWindow。
一个Android健身APP源码(类似KEEP、FEEL、轻+、减约、薄荷等) 详细查看:http://blog.csdn.net/djzhao627/article/details/78988968 同学们,代码有更新,请下载最新版:...
要保持屏幕常亮,我们需要修改`WindowManager.LayoutParams`中的`FLAG_KEEP_SCREEN_ON`标志。在JNI中,我们可以通过Java反射API来修改窗口参数,确保在应用程序运行时屏幕不会自动熄灭。 3. **动态改变应用的显示...
Android 仿 Keep 运动休息倒计时圆形控件 Android 仿 Keep 运动休息倒计时圆形控件是 Android 开发中常用的控件之一。本文将详细介绍 Android 仿 Keep 运动休息倒计时圆形控件的实现原理、使用方法和源码解析。 一...
We developed this as a convenient way to keep multiple apps updated with the latest IAP code for Play and Amazon. About A simple wrapper library that provides sample Google and Amazon in-app purchase...
类似Keep app内的长按结束按钮,长按外沿出现环形进度条,并附带动画效果的自定义View按钮。 详细解析博文:https://blog.csdn.net/Nobody_else_/article/details/113186425
在Android应用开发中,实现类似Google Keep的拖动排序效果是一项常见的需求,它极大地提升了用户交互体验。这个压缩包文件“Android 类google keep拖动排序效果.zip”包含了一个示例项目,名为...
Retired the chapter on dynamic code, the chapter on Android Things, the chapter on SlidingDrawer (from the Widget Catalog), and the chapter on large screen strategies, as well as some other specific ...
I wanted to keep playing this game on Android O, so lifted the source from AOSP, cleaned it up a bit, fixed some things, put it in a Bazel workspace, and published it on Google Play Store. How to ...
在本示例中,我们将探讨如何实现一个类似Keep应用中的PopupWindow效果,即当用户向上滑动时,PopupWindow会向右平滑消失,而当用户向下滑动时,PopupWindow则会从左侧平滑出现。这个功能通过结合PopupWindow、...
If you’re completely new to Android or developing in Kotlin, this is the book for you. Android Apprentice takes you all the way from building your first app, to submitting your app for sale. By ...
- **Keep screen on while plugged in**:当设备充电时保持屏幕常亮,方便开发者在测试过程中无需频繁唤醒设备。 2. **其他调试选项**:除了Development Settings中的设置外,Android Dev Tools还包括一些其他工具...
make sure to keep it plugged in as the screen must be on for scraping to work. Spend your credits by logging into ScraperClub.com and uploading your list of scraping targets. P.S. Everything can ...
This is the Android app for the Hackers on Planet Earth conference for 2010. It's designed to display the HOPE schedule and make it easy to keep track of talks you want to attend. Most of the logic ...
"Prevent Running" hajacks several system API to prevent not-in-use apps in prevent list from running or keep running. Furthermore, it applies to system apps too, specially, support google-family apps...
"Keep in View master" 是一个基于 jQuery 的插件,它主要用于网页布局中,确保特定元素始终在用户视野范围内。这个插件的核心目标是提供一种机制,使得页面滚动时,指定的元素始终保持可见,无论是向上滚动还是向下...
"如何保持大屏屏幕显示一直不待机keepon.7z"这个主题提供了一个解决方案,即使用名为"keepon.exe"的工具来防止屏幕待机。 "keepon.exe"是一个小巧且易于使用的应用程序,它的主要功能是阻止计算机或大屏显示器进入...