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: 120
Registered: ‎02-06-2013
My Device: DAB, DAC, Lost red Z10, Regular Replaced Z10, PlayBook
My Carrier: airtel
Accepted Solution

Creating alarm for low battery

Hi everyone, I just wanted to create notification for the low battery. I know how to create the notification and ring the battery alarm but not sure how that can invoked when the battery level goes below a threshold value. 

 

All examples that I see over Internet is about creating the notification when some button is pressed. How to create the low battery alarm is what I'm looking for. Can anyone provide a sample code or link to do the same ?



Looking for SMTP Servers, Bulk Emails and Bulk SMS services at an affordable price to help boost your business? Look no further. I've the solution for your needs. Contact me now.
Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: Creating alarm for low battery

Hi. You need to look at this to get all the details of the Battery of the Device

 

https://developer.blackberry.com/native/reference/cascades/bb__device__batteryinfo.html

 

Then look at the signals section. I hope this helps Smiley Happy

Developer
Posts: 120
Registered: ‎02-06-2013
My Device: DAB, DAC, Lost red Z10, Regular Replaced Z10, PlayBook
My Carrier: airtel

Re: Creating alarm for low battery

Hey thanks. I didn't notice the signals section though I've been there many times !

I'm not sure how that signal can be used in javascript. Is it something like onLevelChanged() to be used in QML ?

Can you help a bit ? I'm new to Cascades.


Looking for SMTP Servers, Bulk Emails and Bulk SMS services at an affordable price to help boost your business? Look no further. I've the solution for your needs. Contact me now.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Creating alarm for low battery

The easiest way to to it would be to declare is as a QML type and then attach it as an object in your QML, details on how to do that can be found here...

 

http://developer.blackberry.com/native/documentation/cascades/dev/integrating_cpp_qml/#usingcclasses...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 120
Registered: ‎02-06-2013
My Device: DAB, DAC, Lost red Z10, Regular Replaced Z10, PlayBook
My Carrier: airtel

Re: Creating alarm for low battery

Yes, did it. Just posting in case someone needs it.

 

main.qml


attachedObjects: [

 

BatteryInfo{

    id: batteryInfo

   onLevelChanged: {

   if(batteryInfo.level<21)

   systemSound.play(); }

},

 

SystemSound {

   id: systemSound

   sound: SystemSound.BatteryAlarm;

}

 

]

 

Thanks everyone for assistance.



Looking for SMTP Servers, Bulk Emails and Bulk SMS services at an affordable price to help boost your business? Look no further. I've the solution for your needs. Contact me now.