在主active onCreate函数中实现
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setBooleanProperty("loadInWebView", true); super.setIntegerProperty("splashscreen", R.drawable.a); ConnectivityManager cwjManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cwjManager.getActiveNetworkInfo(); if (info != null && info.isAvailable()){ //有网 super.loadUrl("http://192.168.55.175:5000",10000); }else{//没有网 super.loadUrl("file:///android_asset/www/error.html",2000); } }