Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus
Accepted Solution

Prevent the Display from Going to Sleep

[ Edited ]

Hi, Is there a way to prevent the display from dimming?

 

I have stumbled across a few threads, but those threads were dated a few months ago.

 

So I would like to know if theres any new API released to address a solution this problem??

 

Thanksss

 

p.s.: I used the following code but it doesnt work, which is weird

 

    ForeignWindowControl *foreignWindow=ForeignWindowControl::create();
    int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
    screen_set_window_property_iv((screen_window_t)foreignWindow, SCREEN_PROPERTY_IDLE_MODE,&idle_mode);

 

 

 

www.jackdevora.com
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Prevent the Display from Going to Sleep

See my responses in this thread: http://supportforums.blackberry.com/t5/Cascades-Development/Display-Keep-Alive-in-Cascades/m-p/19280...


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Prevent the Display from Going to Sleep

THanks!!

www.jackdevora.com
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: Prevent the Display from Going to Sleep

Hi,

 

Try this

 

#include <bps/bps.h>
#include <bps/navigator.h>
#include <bps/screen.h>
#include <bb/cascades/Window>
#include <bb/cascades/QmlDocument> #include <bb/cascades/Page>
using namespace bb::cascades; MyApp::MyApp(bb::cascades::Application *app) : QObject(app) { QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); Page *root = qml->createRootObject<Page>(); int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE; screen_window_t handle = app->mainWindow()->handle(); screen_set_window_property_iv(handle, SCREEN_PROPERTY_IDLE_MODE, &idle_mode); app->setScene(root); }

 

you have to add LIBS += -lscreen line to your .pro file.