[Interest] Preventing sleep on mobile platforms
Harri Pasanen
harri at mpaja.com
Mon Apr 13 20:34:38 CEST 2015
Android only, but this is what I call from C++:
public static void toggleScreenSaver(boolean onOff)
{
try {
Handler mainHandler = new Handler(Looper.getMainLooper());
if (onOff) {
mainHandler.post(new Runnable() {
@Override
public void run() {
m_instance.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
});
}
else {
mainHandler.post(new Runnable() {
@Override
public void run() {
m_instance.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
});
}
}
catch(Exception e) {
Log.e("Stoppola", "Something Threw", e);
}
}
Regards,
Harri
On 13/04/2015 19:39, Jason H wrote:
> On Android, this seems to correspond to the WAKE_LOCK permission. I was hoping there was a Window.preventSleep property or something like that so I can modify the property at run-time.
>
>
>
>> Sent: Monday, April 13, 2015 at 1:09 PM
>> From: "Thiago Macieira" <thiago.macieira at intel.com>
>> To: interest at qt-project.org
>> Subject: Re: [Interest] Preventing sleep on mobile platforms
>>
>> On Monday 13 April 2015 18:59:34 Gianluca wrote:
>>> Dear Jason,
>>> I don’t think it’s possible. Doing this means override the user’s
>>> preferences about the energy saving. These kind of preferences are usually
>>> beyond the possibility of any Android and iOS app. Anyway, even if it’s
>>> possible, all guides about user experience on mobile platform always
>>> recommend to never override this kind of user preferences.
>> I think it is possible. How do mapping applications do it?
>> --
>> Thiago Macieira - thiago.macieira (AT) intel.com
>> Software Architect - Intel Open Source Technology Center
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list