Android Question [SOLVED] Monitor phone to network connection ?

Discussion in 'Android Questions' started by lemonisdead, Mar 30, 2015.

  1. lemonisdead

    lemonisdead Well-Known Member Licensed User


    I am facing a problem I can not solve : I am in need of detecting if the phone is connected to its network and warn if the connection is lost.

    The only way I had found was to use a service and use PhoneEvents then ConnectivityChanged event. But this seems only to catch the lost of connection when the data are on only.

    Using a broadcast receiver on won't return the "reason" any time.

    Please, do you know a way to detect if the phone is connected to its network without data ?

    Many thanks
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can also check the device ip address with ServerSocket. It should be different than

    Eventually the best way to make sure that there is a live connection is to send a real request and check the result. You can use a timer to send a small http request every minute.
    Beja and lemonisdead like this.
  3. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I think she cares about connectivity to the radio network.
    lemonisdead likes this.
  4. Troberg

    Troberg Well-Known Member Licensed User

    As Erel said, checking a real site is the only way to detect that you are not stuck in a captured portal (those login pages to wifi networks you get to regardless of which URL you specify).
    lemonisdead likes this.
  5. lemonisdead

    lemonisdead Well-Known Member Licensed User


    Excuse me, I had some technical troubles I couldn't reply previously. Thanks for your ideas. I will try.

    Yes, you are right. Thanks for the word "radio network". I will be able to make further googling about. ;)
    thedesolatesoul likes this.
  6. lemonisdead

    lemonisdead Well-Known Member Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice