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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Native Development

Reply
New Developer
tjaartb
Posts: 12
Registered: ‎11-01-2012
My Carrier: simulator

Example of using deviceinfo.h

I am trying to get the serial number of my device. I am quite c++ challenged and am struggling with this. Can someone point me to an example of how to call the deviceinfo.h functions.

 

More sepcifically I am trying to call deviceinfo_identifying_details_get_serial_number

 

Here is my failed attempt that does not compile.

 

Description    Resource    Path    Location    Type
cannot convert 'int*' to 'deviceinfo_identifying_details_t*' in initialization   

cannot convert 'deviceinfo_identifying_details_t' to 'deviceinfo_identifying_details_t*' for argument '1' to 'long long int deviceinfo_identifying_details_get_serial_number(deviceinfo_identifying_details_t*)'   

 

    deviceinfo_identifying_details_t * deviceInfo = new deviceInfo();
    deviceinfo_get_identifying_details(deviceInfo);
    long long deviceinfo_identifying_details_get_serial_number(deviceInfo);
Please use plain text.
BlackBerry Development Advisor
jhoffmann
Posts: 38
Registered: ‎10-26-2011
My Carrier: Rogers

Re: Example of using deviceinfo.h

You don't need to malloc or new the deviceinfo_identifying_details_t struct yourself.  Use the "get" and "free" functions provided:

 

long long serial_number = -1;
deviceinfo_identifying_details_t *id_details = NULL;

int rc = deviceinfo_get_identifying_details(&id_details);
if (BPS_SUCCESS == rc) {
    serial_number = deviceinfo_identifying_details_get_serial_number(id_details);
    deviceinfo_free_identifying_details(&id_details);
}

 

Note that your app must have the "read_device_identifying_information" capability. i.e. your bar descriptor must contain the line:

 

<permission>read_device_identifying_information</permission>

 

Please use plain text.