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

Adobe AIR Development

Reply
Trusted Contributor
Sangram
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -
Accepted Solution

Avoide device auto locking from AIR app

I have a game which is based on Accelerometer and user do not have to interact with the game, other than tilting the device. As a result the device gets locked automatiocally and I want to avoide that.

 

Is there a way by which I can avoide the device from locking in AIR application?

 

Thanks!

Please use plain text.
Developer
KermEd
Posts: 171
Registered: ‎05-18-2009
My Device: NA
My Carrier: NA

Re: Avoide device auto locking from AIR app

Yes, to prevent locking you need to prevent sleep.  This means your app will drain more battery life though, so add events to watch battery life.

 

This is what I have in one of my apps that seems to work well

 

qnx.system.QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;

qnx.system.QNXSystem.system.powerMode = QNXSystemPowerMode.NORMAL;

flash.desktop.NativeApplication.nativeApplication.systemIdleMode = "keepAwake";

Please use plain text.
Trusted Contributor
Sangram
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -

Re: Avoide device auto locking from AIR app

Thanks a lot!

 

Will try and check this one!

Please use plain text.
Trusted Contributor
Sangram
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -

Re: Avoide device auto locking from AIR app

I tried with the code but the sample app can not be loaded on device. I am using the following code:

 

import qnx.system.QNXSystem;
import qnx.system.QNXSystemPowerMode;
import flash.desktop.NativeApplication;

qnx.system.QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;
qnx.system.QNXSystem.system.powerMode = QNXSystemPowerMode.NORMAL;
flash.desktop.NativeApplication.nativeApplication.systemIdleMode = "keepAwake";

 I am using Flash CS5.5 and have added the following in the AS3.0 settings:

C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\air\qnx-air.swc

C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\blackberry\blackberry.swc

C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\qnx\ane\QNXDevice.swc

 

I am publishing this as AIR version and when I publish I get the error message as 'Native methods are not allowed in loaded code'. When I packaged this swf file, the app is not shown and I get to see the blank blackberry screen.

 

Can anyone help me to identify what is wrong here?

 

Thanks!

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Avoide device auto locking from AIR app

Are you including the ANE files?
Do you have "Add platform specific libraries to library path" checked?
Please use plain text.
Trusted Contributor
Sangram
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -

Re: Avoide device auto locking from AIR app

I have included the libraries and ANE files. Also I am using Flash CS5 and there is no option for 'Add platform specific libraries to library path', other than incuding it as mentioned above.

 

Anyways I was able to get it run by selecting the qnx-air.swc as External Link Type.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Avoide device auto locking from AIR app

Good to hear it.
It seems that CS5/6 people have this issue regularly. If you could post exactly what you did to create a new app and what you included? Might help others.
Please use plain text.
Trusted Contributor
Sangram
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -

Re: Avoide device auto locking from AIR app

I have mentioned it over but will detail it again.

 

  • Create a new FLA. Go to 'Publish Settings'.
  • Select 'ActionScript 3.0 Settings'.
  • The add the Library Path for following SWC from the Blackberry 10 AIR SDK
    • qnx-air.swc
    • blackberry.swc
    • QNXDevice.swc.(You won't have swc here, just copy paste .ane file and rename it to .swc)
  • For the 'qnx-air.swc', select the Link Type as External.

That all you need to do to have all QNX events and ANE functionality.

Please use plain text.