BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   DeviceInfo.getDeviceId() gets Wrong PIN (http://www.blackberryforums.com/developer-forum/165755-deviceinfo-getdeviceid-gets-wrong-pin.html)

jeromeng 12-17-2008 02:24 PM

DeviceInfo.getDeviceId() gets Wrong PIN
 
Hi,
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 = "http://mypage.com?PIN=";
StringBuffer sb = new StringBuffer();
sb.append(_url);
sb.append(sPIN);
String full_URL = sb.toString();

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

=======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 09:30 PM.

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