[Interest] Preventing sleep on mobile platforms

Nuno Santos nunosantos at imaginando.pt
Mon Apr 13 19:24:21 CEST 2015


You need to override the app delegate and activities on both iOS and Android and then the following does the trick

iOS:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

    return YES;
}

Android:

public class YourActivity extends QtActivity
{

...

@Override
protected void onStart()
{
    super.onStart();

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}

Nuno Santos
Founder / CEO / CTO
www.imaginando.pt
+351 91 621 69 62

> On 13 Apr 2015, at 18:09, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150413/ab4ce1e6/attachment.html>


More information about the Interest mailing list