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

  • SEARCH
  • Home
  • 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 6476207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:47:47+00:00 2026-05-25T06:47:47+00:00

Right now, I am having application which works with WiFi, but while I am

  • 0

Right now, I am having application which works with WiFi, but while I am going to mobile providers network my application does not working. I have maintained one background service which checks for network, but im not getting how to handle network switch WiFi to Mobile and Mobile to WiFi? I am not getting how to handle WiFi to mobile network switch because already WiFi is enabled and I am not in WiFi coverage area; in this situation I want to get switched to mobile network automatically and vice-versa. My approach is as follows which is not working:

String networkStatus = "disconnected";
            int netType = 0;
            try{
            ConnectivityManager connectivityManager =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
            if(connectivityManager != null ){
                    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

                    if(networkInfo != null){
                        netType = networkInfo.getType();
                        Log.d("Log", "connetion is available");
                    }else {
                        Log.d("Log", "connetion is  not available");
                        return networkStatus;
                    }

                //  if(networkInfo.isAvailable()){  // Old one
if(networkInfo.isAvailable() && networkInfo.isConnected()){  // New change added here
                        if(netType == ConnectivityManager.TYPE_WIFI)
                            {}
                        else if(netType == ConnectivityManager.TYPE_MOBILE )
                            {}
                            }
                        }
                    }catch(Exception e){
            Log.d("Log", "checkNetworkConnection" + e.toString());
            return networkStatus;
        }

Already I have read many posts over hear still not getting idea. Can anyone give me any idea or url where I can get same approach to implement?

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-25T06:47:48+00:00Added an answer on May 25, 2026 at 6:47 am

    I got the solution:

    String networkStatus = "disconnected";
                int netType = 0;
                try{
                ConnectivityManager connectivityManager =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
                if(connectivityManager != null ){
                        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    
                        if(networkInfo != null){
                            netType = networkInfo.getType();
                            Log.d("Log", "connetion is available");
                        }else {
                            Log.d("Log", "connetion is  not available");
                            return networkStatus;
                        }
    
                    //  if(networkInfo.isAvailable()){  // Old one
    if(networkInfo.isAvailable() && networkInfo.isConnected()){  // New change added here
                            if(netType == ConnectivityManager.TYPE_WIFI)
                                {}
                            else if(netType == ConnectivityManager.TYPE_MOBILE )
                                {}
                                }
                            }
                        }catch(Exception e){
                Log.d("Log", "checkNetworkConnection" + e.toString());
                return networkStatus;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've already looked around but couldn't find the exact solution/problem I'm having right now.
The idea I'm playing with right now is having a multi-leveled tier system of
We are having this problem with a controller right now; the controller looks like
I'm having an odd probably with rails right now... a class is being defined
I'm working on a Flash project right now and I am having to force
I'm having troubles with the order of my code in my program. right now
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
I am developing a library for Android applications which does not use native code
I'm creating web application for my friend, a tutor school system. Now, I'm having
I'm working with an application that utilizes the Google Weather API, right now I

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.