Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 838469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:18:36+00:00 2026-05-15T05:18:36+00:00

I have a small doubt regarding network connection procedure in Android. My scenario is

  • 0

I have a small doubt regarding network connection procedure in Android.

My scenario is like,
I am connecting to remote server over TCP using 3G. After it got connected, I enabled Wi-Fi. Android has switched to WiFi. And, still connection is alive with server, means there is no connection drop.

Here, I want to know one thing.
When N/W is switched from 3G to Wi-Fi, will Android (or any other) device change its IP address as well ?
and if it changes its IP, will that old connection is valid ? (means, on new IP, there should be again new connection.)

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:18:37+00:00Added an answer on May 15, 2026 at 5:18 am

    The way I understand is that the IP address will change. When the phone switches on to WiFi, it is your router that assigns the device an IP address. I suspect that Android might be restarting the IP stack (just a conjecture though) and I don’t remember seeing any kind of a “handoff” mechanism to let the device have the same IP address. While it maybe theoretically possible, I am not sure how complicated it can make thing 🙂 In addition, Android has only one network interface card, so it is not possible for it to retain both the IP addresses. If it switches to WiFi, it retains ONLY the Wifi IP address.

    I did observed from my experience, a scenario like this will fail:

    • Android is connected via 3G initially
    • Android Application sends a HTTP GET to a web server
    • Android senses a better WiFi connectivity and switches from 3G

    In this case, the GET request fails.

    Possible solutions:

    • Try multiple times: 3 times (or a different magic number, but 3 worked for me in most cases) using a try-catch-repeat should solve most problems.
    • Use code like this to check for network connectivity and proceed from there:

      if(!isOnline()) {
        Log.e("OFFLINEERROR", "No Network Connectivity");
      }
      
      public boolean isOnline() {
        try {
          ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
          return cm.getActiveNetworkInfo().isConnectedOrConnecting();         
        } catch(Exception e) {
          //Returned a null so no Internet connection!
          return false;
        }
      }
      
    • Chunk your transfers (this way even if you lose your connection, you can still finish the transfer).

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.