<!-- Dialog box title -->
<string name="loadSuspendedTitle">No network connection</string>
<!-- Dialog box message -->
- <string name="loadSuspended">The page will continue loading after connection has been restored.</string>
+ <string name="loadSuspended">The Browser cannot load this page because there
+ is no internet connection.</string>
<!-- Menu item -->
<string name="clear_history">Clear history</string>
<!-- History screen title; appears in title bar -->
import android.hardware.SensorListener;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.Uri;
import android.net.WebAddress;
import android.net.http.EventHandler;
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(
ConnectivityManager.CONNECTIVITY_ACTION)) {
- boolean down = intent.getBooleanExtra(
- ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
- onNetworkToggle(!down);
+ NetworkInfo info =
+ (NetworkInfo) intent.getParcelableExtra(
+ ConnectivityManager.EXTRA_NETWORK_INFO);
+ onNetworkToggle(
+ (info != null) ? info.isConnected() : false);
}
}
};
}
updateInLoadMenuItems();
if (!mIsNetworkUp) {
- if ( mAlertDialog == null) {
- mAlertDialog = new AlertDialog.Builder(BrowserActivity.this)
- .setTitle(R.string.loadSuspendedTitle)
- .setMessage(R.string.loadSuspended)
- .setPositiveButton(R.string.ok, null)
- .show();
- }
+ createAndShowNetworkDialog();
if (view != null) {
view.setNetworkAvailable(false);
}
}
} else {
mIsNetworkUp = false;
- if (mInLoad && mAlertDialog == null) {
- mAlertDialog = new AlertDialog.Builder(this)
- .setTitle(R.string.loadSuspendedTitle)
- .setMessage(R.string.loadSuspended)
- .setPositiveButton(R.string.ok, null)
- .show();
- }
+ if (mInLoad) {
+ createAndShowNetworkDialog();
+ }
}
WebView w = mTabControl.getCurrentWebView();
if (w != null) {
}
}
+ // This method shows the network dialog alerting the user that the net is
+ // down. It will only show the dialog if mAlertDialog is null.
+ private void createAndShowNetworkDialog() {
+ if (mAlertDialog == null) {
+ mAlertDialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.loadSuspendedTitle)
+ .setMessage(R.string.loadSuspended)
+ .setPositiveButton(R.string.ok, null)
+ .show();
+ }
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {