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

Java Development

Reply
Developer
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified
Accepted Solution

Not able to use SIMCardInfo.getIMSI()

hi,

i need to use pin number and phone number of the device but you know if phone number is not set, we can't get that, so i decided to use IMSI but i am not able to convert this into String.

 

 

byte imsi[]=SIMCardInfo.getIMSI();

give me this = [B@99721fbd in simulator and when i deployed it on device, i got [B at start.

 

String str=new String(imsi); gives me some square boxes

 

any idea why?

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Highlighted
Developer
Posts: 212
Registered: ‎07-18-2008
My Device: Storm 9550

Re: Not able to use SIMCardInfo.getIMSI()

the [B@99721fbd i is correct.

This happens when you print out a byte array.

 

The problem why you see the square boxes when converting it to string is that the documentation says:

"IMSI in BCD format"

http://en.wikipedia.org/wiki/Binary-coded_decimal

 

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Developer
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified

Re: Not able to use SIMCardInfo.getIMSI()

yeh  i did see that but now i am searching how can i convert this into to integer or string.?

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Developer
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified

Re: Not able to use SIMCardInfo.getIMSI()

Any one who used this,Please guide me !

How can i use this IMSI either as string or int.

 

 

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Developer
Posts: 212
Registered: ‎07-18-2008
My Device: Storm 9550

Re: Not able to use SIMCardInfo.getIMSI()

try something like:

 

    public String toString(byte[] pBuffer)
    {
        StringBuffer oBuffer = new StringBuffer();  
        for (int i=0; i<pBuffer.length; i++)
        {
           oBuffer.append(String.valueOf(pBuffer[i]));
        }
        return oBuffer.toString();           
    }

 

If your problem was solved, please mark answer as "Accepted solution"
If your want to thank, click the "kudo" symbol
___________
visit me: http://mobilejavadevelopment.blogspot.com/
visit the Berlin BlackBerry Developer Group: http://berlinblackberrydevelopers.blogspot.com/
Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Not able to use SIMCardInfo.getIMSI()

Hi, If you're using the simulator, why don't you try to print it to the console window: Syse.out.print(string) and if you're using a real device you can use either Dialog.inform(string) or register to the event log and write it there.
Developer
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: Not able to use SIMCardInfo.getIMSI()

Use this:

GPRSInfo.imeiToString(SimCardInfo.getIMSI());

Developer
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified

Re: Not able to use SIMCardInfo.getIMSI()

Thanks for all, who put some effort to solve my problem.

I really appreciate that.

Cheers!

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!