<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to prevent device from sleep while application is running]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have an android application to show slideshow. The device after some time, gets the screen dim, and goes off and locked. How can I avoid this, until user quits the application.</p>
<p dir="auto">Like similar to "android.permission.WAKE_LOCK" and call some functions.. I'm not sure exactly.</p>
<p dir="auto">Thanks in advance :)</p>
]]></description><link>https://forum.qt.io/topic/40379/how-to-prevent-device-from-sleep-while-application-is-running</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 06:04:58 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/40379.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Apr 2014 13:40:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to prevent device from sleep while application is running on Sun, 20 Apr 2014 05:45:31 GMT]]></title><description><![CDATA[<p dir="auto">peterlin82 : can you tell me where to add? I have no idea where is QtActivity.java</p>
<p dir="auto">My application code is just same like desktop application:</p>
<p dir="auto">@#include "pricechecker.h"<br />
#include &lt;QApplication&gt;</p>
<p dir="auto">int main(int argc, char *argv[])<br />
{<br />
QApplication a(argc, argv);<br />
PriceChecker w;<br />
w.show();</p>
<pre><code>QFile styleFile &amp;#40;":/style/styleFile.qss"&amp;#41;;
if (true == styleFile.open(QFile::ReadOnly&amp;#41;)
{
    QString style(styleFile.readAll());
    a.setStyleSheet(style);
}

return a.exec(&amp;#41;;
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">I am using Qt 5.2</p>
]]></description><link>https://forum.qt.io/post/224113</link><guid isPermaLink="true">https://forum.qt.io/post/224113</guid><dc:creator><![CDATA[Abin]]></dc:creator><pubDate>Sun, 20 Apr 2014 05:45:31 GMT</pubDate></item><item><title><![CDATA[Reply to How to prevent device from sleep while application is running on Thu, 17 Apr 2014 08:12:47 GMT]]></title><description><![CDATA[<p dir="auto">You can add<br />
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);<br />
on QtActivity.java</p>
]]></description><link>https://forum.qt.io/post/223800</link><guid isPermaLink="true">https://forum.qt.io/post/223800</guid><dc:creator><![CDATA[peterlin82]]></dc:creator><pubDate>Thu, 17 Apr 2014 08:12:47 GMT</pubDate></item><item><title><![CDATA[Reply to How to prevent device from sleep while application is running on Thu, 17 Apr 2014 05:52:13 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the reply.</p>
<p dir="auto"><em>Screen Lock - &gt; select NONE</em> will only just doesn't lock the device, but the screen will dim and turns off after the set timeout in <em>setting-&gt;Display-&gt;Dimmer</em> and <em>Settings-&gt;Display-&gt;Sleep</em>. These settings doesn't have a NONE option. :(</p>
<p dir="auto">So from Qt there is no way to acquire this?</p>
]]></description><link>https://forum.qt.io/post/223790</link><guid isPermaLink="true">https://forum.qt.io/post/223790</guid><dc:creator><![CDATA[Abin]]></dc:creator><pubDate>Thu, 17 Apr 2014 05:52:13 GMT</pubDate></item><item><title><![CDATA[Reply to How to prevent device from sleep while application is running on Wed, 16 Apr 2014 17:07:01 GMT]]></title><description><![CDATA[<p dir="auto">One solution, if I'm not wrong, is :</p>
<p dir="auto">[ANDROID]<br />
Go to Settings -&gt; Security -&gt; Screen Lock and select NONE</p>
<p dir="auto">[iOS]<br />
Go to Settings -&gt; General -&gt; Auto-Lock and select NEVER</p>
<p dir="auto">I'm not sure this can be done programatically (probably not using Qt). But (on Android) using Java Native Interface (JNI), it can :</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/4736354/how-to-enable-or-disable-autolock-in-android" target="_blank" rel="noopener noreferrer nofollow ugc">http://stackoverflow.com/questions/4736354/how-to-enable-or-disable-autolock-in-android</a></p>
]]></description><link>https://forum.qt.io/post/223742</link><guid isPermaLink="true">https://forum.qt.io/post/223742</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 16 Apr 2014 17:07:01 GMT</pubDate></item></channel></rss>