A view can only have a single parent. The view that you are adding is already part of another view hierarchy. If you really want to reuse it (I would suggest you probably don't) then you have to detach it from its parent in its existing view hierarchy.
Android-Stuff
Android development updates, Help desk and Knowledge Share Point for Android beginner ...!!!
Monday, September 12, 2011
Handle WiFi to Mobile network switch programatically?
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;
}
Subscribe to:
Posts (Atom)