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
New Developer
garimasharma
Posts: 62
Registered: ‎01-19-2010
My Device: storm
My Carrier: storm

check internet connection

Hi,

 

Please anyone suggest me how to check internnet connection through java application.

i have usedthe following code

 

if((CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS)))|| (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_BIS_B)) != false)

             {

                 add(new LabelField("Internet  available"));

             }
             else
             {
                 add(new LabelField("Not  available"));
            
             }

 

 

 

it gives false in both cases either i start mds services or stop it.

 

 

please give me any suggestion!!

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: check internet connection

the simulator does not have MDS or BIS coverage. you can use COVERAGE_CARRIER in case of the simulator and/or test your code on a real device.

----------------------------------------------------------
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
Please use plain text.
New Developer
garimasharma
Posts: 62
Registered: ‎01-19-2010
My Device: storm
My Carrier: storm

Re: check internet connection

[ Edited ]

please provide me some code how to check connection through simulator.

 

Can i check wi-fi connection?

Please use plain text.
Developer
DAquilina
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: check internet connection

I'm pretty sure this would be covered not by the device simulator, but the MDS simulator. I suppose an easy way to test if you have an internet connection would be to attempt to open an httpConnection or invoke a browser, and throw an exception if they fail. THen again, I've never tried this myself.

 

Good luck,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Please use plain text.
Contributor
v_vyas
Posts: 23
Registered: ‎04-18-2011
My Device: 9700
My Carrier: AT&T

Re: check internet connection

Hi Guys,

 

What is the easiest way to find internet connection on Blackberry device and simulator without opening httpconnection to "google" or anything else and should work any case whether wifi or MDS..

 

Please suggest a way..

 

Thanks,

 

 

Please use plain text.
Contributor
cyberlinks
Posts: 17
Registered: ‎01-13-2012
My Device: i dont have blackberry
My Carrier: nokia

Re: check internet connection

how to know about internet connection

if internet is active in computer

if (internet == active )

true

else

false

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: check internet connection

please open an own thread with your question
----------------------------------------------------------
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
Please use plain text.
Contributor
cyberlinks
Posts: 17
Registered: ‎01-13-2012
My Device: i dont have blackberry
My Carrier: nokia

Re: check internet connection

 i am still having problem

my code is

public HttpConnection openConnection(){
        HttpConnection conn=null;
        try {
            conn = (HttpConnection)Connector.open("http://www.google.com"+";deviceside=true");
            conn.setRequestMethod(HttpConnection.GET);

            if((conn.getResponseCode() == HttpConnection.HTTP_OK)){
                LabelField label = new LabelField("true");
                add(label);
                System.out.println("Create connection sucessfully::::::::::::");
                }
            else{
                LabelField label = new LabelField("false");
                add(label);
                System.out.println("Create connection not sucessfully>>>>>>>>>>>>");
            }

        } catch (ConnectionNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }

        return conn;


    }

and its giving result false

it should be true

help me!!!!!

Please use plain text.
Contributor
bogdannistor
Posts: 14
Registered: ‎01-20-2011
My Device: BlackBerry Bold 9700
My Carrier: Orange

Re: check internet connection

public static boolean isInternetConnectionAvailable() {
    return checkSignal() || checkWifi();
}
	
private static boolean checkSignal() {
    return RadioInfo.getState() != RadioInfo.STATE_OFF && RadioInfo.getSignalLevel() != 
            RadioInfo.LEVEL_NO_COVERAGE;
}
	
private static boolean checkWifi() {
    if ((RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN ) != 0 ) {
        return CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT, RadioInfo.WAF_WLAN, true);
    }
	    
    return false;
}

 

Please use plain text.