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
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone
Accepted Solution

COnnection String returns null

HI my app works perfectly fine on 3G network but when i try to use interface=wifi to make a connection using wifi an IOException is thrown showing its null. can someone help me with this please?

 

Thanks in advance

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

Re: COnnection String returns null

What's null?

New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: COnnection String returns null

when i try to open the connection string it thorws an IOException saying null.

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

Re: COnnection String returns null

So the toString() method of the Exception thrown returns null?

 

Can you show us

 

a) the URL you are using - it should end with the following (after removing the double quotes:

";interface=wifi".

b) the code that detects the Exception?

 

Have you reviewing the KB article I pointed you at in your other Thread?

New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: COnnection String returns null

Hi I did the same thing as mentioned in the KB article you pointed at me. and have a look at this please this is what im tying to do

 

try
        {
            if(CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT))
            {
                clientSocket = (StreamConnection) Connector.open("socket://" + MyLiveGuardAppServerIP + ":" + MyLiveGuardAppPort+";deviceside=true");
            }
            else
            {
                clientSocket = (StreamConnection) Connector.open("socket://" + MyLiveGuardAppServerIP + ":" + MyLiveGuardAppPort+";interface=wifi");
                System.out.println("LiveGuard Client Socket on WIFI " + clientSocket);
            }
        }
        catch (InterruptedIOException e)
        {
            e.printStackTrace();
            System.out.println("LiveGuard Could not connect to server. " + e.getMessage());
            Dialog.alert("Could not connect to server");
            
            UiApplication.getUiApplication().invokeLater(new Runnable()
            {
                public void run()
                {                    
                    UiApplication.getUiApplication().pushModalScreen(pp);                    
                }
            });

            return;
        }
        catch (IllegalArgumentException e)
        {
            e.printStackTrace();
            System.out.println("LiveGuard Could not connect to server. " + e.getMessage());
            Dialog.alert("Could not connect to server");
            
            UiApplication.getUiApplication().invokeLater(new Runnable()
            {
                public void run()
                {                    
                    UiApplication.getUiApplication().pushModalScreen(pp);                    
                }
            });    

            return;
        }
        catch (IOException e)
        {
            e.printStackTrace();
            System.out.println("LiveGuard Could not connect to server. " + e.getMessage());
            Dialog.alert("Could not connect to server");
            
            UiApplication.getUiApplication().invokeLater(new Runnable()
            {
                public void run()
                {
                    
                    UiApplication.getUiApplication().pushModalScreen(pp);
                    
                }
            });
            return;
        }

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

Re: COnnection String returns null

And when you run this you see?

 

Have you tried the SocketDemo that comes with your tooling?  At least look at the code to see what it does that is different to what you are doing. 

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

Re: COnnection String returns null

dialog alert cannot be used outside the event thread. but i already told you that.

your code is bogus. you check if coverage is available and do a direct connection. if no coverage is available you do a wifi connection.
coverageinfo takes wifi into account.

is you don't have to support an os lower than 5 use ConnectionFactory and be done with it.

It seems that understanding what happens is not your highest priority as you open thread after thread and ignore (or don't understand) the KB articles we post to assist you.
----------------------------------------------------------
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
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: COnnection String returns null

It returns an IOException and which gives me a log saying "null" im wondering that the connection URL doest get assigned to the clientSOcket variable. anyways Il have a look at the socketDemo

 

cheers

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

Re: COnnection String returns null

Sorry I am not trying to be picky here, but this line, which is the line I suspect you are getting to, can not just display

null:

System.out.println("LiveGuard Could not connect to server. " + e.getMessage());

 

I started the response to this Thread with the question "Whats null".  I still actually don't know what the answer to that question is.

 

If you want peple to help you, you have to help them.  So please answer all the questions and follow all the instructions.  If you decide not to do this at least explain why you haven't.  That at least will alert the responders as to what you actually have done and they can come back to you to explain why you really should have done what was asked, if it is still relevant.

 

And remember you are explaining your problem to someone who has only seen a small proportion of your code, does not know your knowledge level or your experience or your set up, so you need to be as detailed as you possibly can. 

New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: COnnection String returns null

Hi Peter sorry about that.

 

Well to answer your question int he first place "whats null?" the IOException log returns a null. I managed to sort it out Peter because I had some setting issue on my blackberry it works fine. thanks for you help.

 

And @simon I know what you mean and i havent ignored any of hte help you have provided. I am a beginner and I didnt know about CoverageInfo having wifi included in it. I left the the UI Alerts just for my debugging purposes and I am defiitely going to remove them all because i havent finalised anything on my code yet.

 

Cheers