How to handle WiFi to Mobile network switch programatically?
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()){
						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.
How to handle WiFi to Mobile network switch programatically?
===

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()){
						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.