×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    2

    Question Check Internet Connection on S40 Platform

    How can i check if there is an active internet connection before i download something.
    I am using Java ME and the Nokia SDK 2.0 for Java.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: Check Internet Connection on S40 Platform

    I see that you got some answers in: http://www.developer.nokia.com/Commu...ork-connection

    As far as I know you don't have such an API until the latest Asha platform, i.e you would need to be targeting 501 and newer devices only.

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Check Internet Connection on S40 Platform

    I dont think that it should matter to you if a connection exists before you start download because the connection can be interuptted at any sec (going into an elevator, pressing the end key, etc)
    so you should always think best case scenario and start to download and plan for worst case scenario and handle exception in connections request or stream reading properly.

  4. #4
    Registered User
    Join Date
    Jun 2013
    Posts
    19

    Re: Check Internet Connection on S40 Platform

    add import javax.microedition.io.Connector;

    Make a Function of below :

    try
    {
    Connector.open("http://www.nokia.com");
    }
    catch(IOException e)
    {

    }

    call this function whenever you want to check for Internet Connection.


    Hope This Serves your purpose

  5. #5
    Regular Contributor
    Join Date
    Dec 2012
    Location
    Indonesia,DKI Jakarta
    Posts
    87

    Re: Check Internet Connection on S40 Platform

    Hello guys,

    I think this thread is the right place for asking and discuss about handling connection in J2ME, So my question is, How do i ping the server before i sending data then if i got reply i send the data, if not i'll keep ping until i got reply....?



    Best Regards,
    Iqbal

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: Check Internet Connection on S40 Platform

    One easy way would be to make a HTTP GET in which you would not send sny data from either party.

  7. #7
    Regular Contributor
    Join Date
    Dec 2012
    Location
    Indonesia,DKI Jakarta
    Posts
    87

    Re: Check Internet Connection on S40 Platform

    Quote Originally Posted by symbianyucca View Post
    One easy way would be to make a HTTP GET in which you would not send sny data from either party.
    Sorry symbianyucca, What is sny..?.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: Check Internet Connection on S40 Platform

    Most probably that is any, one button shifted right on the keyboard (assuming an a-s-d-f... layout).
    Last edited by wizard_hu_; 2013-06-27 at 10:44.

  9. #9
    Registered User
    Join Date
    Jun 2013
    Posts
    22

    Re: Check Internet Connection on S40 Platform


  10. #10
    Regular Contributor
    Join Date
    Dec 2012
    Location
    Indonesia,DKI Jakarta
    Posts
    87

    Re: Check Internet Connection on S40 Platform

    Quote Originally Posted by wizard_hu_ View Post
    Most probably that is any, one button shifted right on the keyboard (assuming an a-s-d-f... layout).
    OK, . that's why i ask him.

  11. #11
    Regular Contributor
    Join Date
    Dec 2012
    Location
    Indonesia,DKI Jakarta
    Posts
    87

    Re: Check Internet Connection on S40 Platform

    Quote Originally Posted by minirich View Post
    Ok, that's good to. i'll check. Thank you minirich.

  12. #12
    Regular Contributor
    Join Date
    Dec 2012
    Location
    Indonesia,DKI Jakarta
    Posts
    87

    Re: Check Internet Connection on S40 Platform

    Quote Originally Posted by symbianyucca View Post
    One easy way would be to make a HTTP GET iGEn which you would not send sny data from either party.
    I have try with GET and POST Http. But both of way still not success. The first with GET, the result is 301 response code. The second way with POST i got 405 response code. here is the url for my code:
    http://paste.org/65708. Somebody can help..??

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Check Internet Connection on S40 Platform

    Http codes 301 (and 302) means that the page has been moved and you are being redirected, these codes comes from the server which mean you DO have internet connection so when you check for your response code and compare it to HTTP_OK just add also the 301 and 302 codes (if its just for simple ping verification), the 405 response code means you had a server error trying use unsupported operation (in this case it would be using the POST instead of the GET)

  14. #14
    Registered User
    Join Date
    Jun 2013
    Posts
    22

    Re: Check Internet Connection on S40 Platform

    Quote Originally Posted by muhamad.iqbal View Post
    Ok, that's good to. i'll check. Thank you minirich.
    You're welcome, If you are been redirected and you use an ConnectionRequest object, then the ConnectionRequest object has the method setFollowRedirects( boolean )

    Perhaps it works

Similar Threads

  1. Check internet connection speed programatically
    By hansorkrutor in forum Wired and Wireless interfaces (Closed)
    Replies: 2
    Last Post: 2011-06-03, 16:08
  2. 'No Internet Connection' check
    By chandran.biju007 in forum Symbian
    Replies: 5
    Last Post: 2010-09-28, 07:43
  3. problem in networking midlet (connection problems. check your internet/proxy settins)
    By omer.koylu in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2010-08-13, 15:16
  4. Would you like to Check your Gmails Without Internet Connection?
    By austin007 in forum News and Announcements
    Replies: 1
    Last Post: 2010-01-21, 06:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×