当我将我的机器人改为飞机模式时,AVD发送给我强制关闭对话框,请在我的代码中调试我的问题:
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.Toast;
//Set Activity Irancell:
public class Irancell extends Activity {
final String offlineMessageHtml = "DEFINE THIS";
private Context c;
private boolean isConnected = true;
WebView Irancell_Charge;
//Start App Code at here:
@Override
// Set iCicle Void:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
c=this;
//check for connectivity:
ConnectivityManager connectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
if (ni.getState() != NetworkInfo.State.CONNECTED) {
// record the fact that there is not connection
isConnected = false;
}
//Text Label:
Toast.makeText(this, "MTN Irancell Recharge Cards...", Toast.LENGTH_LONG).show();
//Load Irancel Buy Creadit Page:
Irancell_Charge=new WebView(this);
setContentView(Irancell_Charge);
Irancell_Charge.setNetworkAvailable(isConnected);
Irancell_Charge.getSettings().setJavaScriptEnabled(true);
Irancell_Charge.loadUrl("http://www.echarge.ir/Templates/irancellshop/m/");
}
public boolean shouldOverrideUrlLoading(WebView view, String url){
if (isConnected) {
return false;
} else {
view.loadData(offlineMessageHtml, "text/html", "utf-8");
return true;
}
}
}
由于