If you access the browser by disabling 3G (clicking F8) , still browser works without any issues. I want similar type of functionality in my app , how can I implement same in my app.
Currently we are using following code in our app:
protected boolean isNetworkCoverageAvailable()
{
boolean result = false;
Context oContext = AndroidContext.getContext();
ConnectivityManager connMgr = (ConnectivityManager) oContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if(wifi.isConnected() == true){
开发者_如何学运维 result = true;
} else if (mobile.isConnectedOrConnecting() == true){
result = true;
} else {
result = oMgr.getDataState() == TelephonyManager.DATA_CONNECTED;
}
Log.d(TAG, "Result: " + result + "");
return result;
}
The app is working for Wi-Fi and 3G enabled , but I want app needs to activate 3G automatically if 3G is suspended because of unusuability of device.
How can I do this in Android ?
I don't think you can enable 3G programmatically. The user chooses to disable or enable it.
What you can do is ask the user to enable WIFI or 3G and direct them to the settings screen? I think I have seen apps do this before.
精彩评论