我怎样才能让我的屏幕上使用运行的应用程序的背景下

我怎样才能让我的屏幕上使用运行的应用程序的背景下

本文介绍了我怎样才能让我的屏幕上使用运行的应用程序的背景下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做,保持在屏幕上即使该应用程序在后台运行的应用程序。

I need to make an app that keeps the screen on even when the app is running in the background.

我试过:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

但是,只有当应用程序正在运行,不能作为服务运行工作。

But it only works when the app is running and can't run as a service.

我也试过,但wakelocks和SCREEN_BRIGHT_WAKE_LOCK FULL_WAKE_LOCK均出现了德precated。唯一剩下的就是激活锁定PARTIAL_WAKE_LOCK。

I've also tried wakelocks but SCREEN_BRIGHT_WAKE_LOCK and FULL_WAKE_LOCK have both been deprecated. The only wakelock left is PARTIAL_WAKE_LOCK.

有什么方法来保持屏幕上使用PARTIAL_WAKE_LOCK,ACQUIRE_CAUSES_WAKEUP,以及一些循环?

Is there someway to keep the screen on using the PARTIAL_WAKE_LOCK, ACQUIRE_CAUSES_WAKEUP, and some loops?

坦白说,我有Java或应用程序开发没有真正的经验,我已经指派这项任务作为一名实习生,因此任何帮助将是AP preciated。

Frankly I have no real experience with Java or app development and I've been assigned this task as an intern so any help would be appreciated.

推荐答案

的反应是不,你不能。至于你说的这样做的唯一的办法就是使用去precated API。作为替代方案,你可以使用一个活动的透明的主题,但如果例如preSS home键和活动的用户不再是在前台你失去反正。

The response is no, you can't. As you said the only way of doing that is using deprecated api. As alternative you could use an activity with transparent theme but if the user for example press the home button and the activity is no more in foreground you loose anyway.

这篇关于我怎样才能让我的屏幕上使用运行的应用程序的背景下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:12