BlackBerry Forums Support Community

BlackBerry Forums Support Community (
-   Developer Forum (
-   -   DeviceInfo.getDeviceId() gets Wrong PIN (

jeromeng 12-17-2008 02:24 PM

DeviceInfo.getDeviceId() gets Wrong PIN
I used the code snippet below to retrieve my device PIN and got wrong values for both the simulator and real device (8310); the retrieved PIN was a 9 digit int (all are numbers) instead of an 8 digit string of the format 251CE***. What am I doing wrong?

Pls help

====== CODE STARTS========
import net.rim.device.api.system.DeviceInfo.*;

//retrieve device PIN
int _PIN = DeviceInfo.getDeviceId();

//convert INT to String
String sPIN = ""+ _PIN;

//append PIN to URL
String _url = "";
StringBuffer sb = new StringBuffer();
String full_URL = sb.toString();

//display PIN and URL on screen
RichTextField _path1 = new RichTextField(sPIN);
RichTextField _path2 = new RichTextField(full_URL);

=======CODE ENDS============

Dougsg38p 12-17-2008 02:42 PM

You need to convert the int to a string in hexadecimal format.

For example, 254 becomes EF, etc.

jeromeng 12-17-2008 02:43 PM

Thx, I was able to solve it with this:

//retrieve the device PIN
String _PIN = (Integer.toString(DeviceInfo.getDeviceId(),16)).to UpperCase();

All times are GMT -5. The time now is 05:46 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.