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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Regular Contributor
Posts: 52
Registered: ‎10-31-2010
My Device: Not Specified
My Carrier: developer
Accepted Solution

Illegal state exception while reading MCC

Hi,

I'm using the above method to read MCC


    private void readMCC() {
        log("reading mcc");
        int mccInt = RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex());
        log("mcc" + Integer.toString(mccInt));
        mcc = Integer.toHexString(mccInt);
        log("mcc" + mcc);
       
    }
It's working fine for the first time after installation. If i restart my phone it's throwing illegal state exception .

But i'm get printed current network index correctly.

Can anybody help me to resolve this ?

Thanks in advance.
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Illegal state exception while reading MCC

it may be possible that the network is not available at startup resp. by the time you execute this code.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Regular Contributor
Posts: 52
Registered: ‎10-31-2010
My Device: Not Specified
My Carrier: developer

Re: Illegal state exception while reading MCC

Thanks Simon,

But me too guess the same. Though when i printed RadioInfo.getCurrentNetworkIndex() separately it's 

get printed as 0 without any exceptions.

 

Printing zero , will it mean no RadioInfo thr ?

 

How can i solve this ?

 

Thanks in advance.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Illegal state exception while reading MCC

[ Edited ]

Here is a good pattern for 'start-up' processing that should mean you can get your Radio information once the device has properly started. 

 

http://supportforums.blackberry.com/t5/Java-Development/Write-safe-initialization-code/ta-p/444795

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Illegal state exception while reading MCC

while peters suggestion is of course valid it does not solve the problem.

some people have devices which connect only after a prompt, or the user needs to start the network manually.

 

i would suggest that you check http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/system/RadioInfo.html#getNumbe... first, and if there are none register a radiostatuslistener (which you most likely have anyhow to get notified about mcc changes)

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 52
Registered: ‎10-31-2010
My Device: Not Specified
My Carrier: developer

Re: Illegal state exception while reading MCC

Thanks a lot Peter & Simon for the sugesstions Smiley Happy.

 

Peter's suggesstion worked well.

 

Thanks again

Regular Contributor
Posts: 52
Registered: ‎10-31-2010
My Device: Not Specified
My Carrier: developer

Re: Illegal state exception while reading MCC

There an iterface RadiStateListner to listen , when the status change. Am i right ?

Hope using that i can resolve this issue.

 

Hence i'm using some other methods also needs to iniialize i think it's better to use systemListner as Peter suggested.

 

Thanks.

Regular Contributor
Posts: 52
Registered: ‎10-31-2010
My Device: Not Specified
My Carrier: developer

Re: Illegal state exception while reading MCC

Hi,


I'm reading MCC when application in auto startup

mcc =Integer.toHexString(RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex()));


Previously i got illegal state exception and now it is no longer existing after setting the system listeners.

But still i'm getting null value and illegalArgumentException.


I have tried by setting RadiStatusListeners as well.But didn't work.


Can anyboday help me on this ?


It's urgent Smiley Sad

 

Thanks in advance.