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

Posts: 83
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

BBM registered app


i have developed a simple app that shows the current battery percentage....now i want to register this app to BBM..I tried doing this using RegistrationHandler class..the app gets registered to BBM,but now the main UI doesnt show the battery temperature...just a blank screen..plz help




this is the app.cpp file


#include "App.hpp"

#include <bb/cascades/AbstractPane>
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/device/BatteryInfo>
using namespace bb::cascades;
using namespace bb::device;

App::App(bb::cascades::Application *app)
    : QObject(app)

//! [0]
void App::show()
	qmlRegisterUncreatableType<bb::device::BatteryChargingState>("bb.device", 1, 0, "BatteryChargingState", "");
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(Application::instance());

    qDebug()<<"In App";
    // Provide access to signals, slots and properties of App to QML
    qml->setContextProperty("app", this);
    //qml->setContextProperty("_battery", &batteryInfo);
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Do further initialization
    // You can use RegistrationHandler::context() now to access the bound BBM context

int App::Level() const
	qDebug()<<"In Level";
int	lev=batteryInfo.level();





#ifndef APP_HPP
#define APP_HPP

#include <QObject>
#include <bb/device/BatteryInfo>
namespace bb { namespace cascades { class Application; }}
 * The main business logic object in the application.
 * This object normally provides signals, slots and properties
 * that are accessed by the main page of the application's UI.
//! [0]
class App : public QObject

    // Add your Q_PROPERTY declarations here.

    bb::device::BatteryInfo batteryInfo;
    App(bb::cascades::Application *app);
    Q_INVOKABLE int Level() const;

public Q_SLOTS:
    void show();

    // Add your slot declarations here.

    // Add your signal declarations here.
//! [0]





import bb.cascades 1.0

Page {
    Container {
        layout: DockLayout {}
         Button {
                    id: button
                    objectName: "button"
                    text: "percentage"
                    onClicked: {
                        total.text = "the battery percentage=" +app.Level()+" celsius";
        Label {
            id: total
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center

            text: "the battery percentage="