當我在某些設備上運行應用程序時,一切正常,但用戶通常使用的其他設備,但隨着時間的推移,應用程序將退出並在每次打開後寫入應用程序時不幸停止工作。卸載並重新安裝後,只能運行約10分鐘,然後再次出現相同的錯誤。當我報告玩這個錯誤時Google向我發佈了這條消息。有誰知道該怎麼辦?對不起,英文不好。Android應用程序關閉
java.lang.NullPointerException
at www.clientbook.cz.ClientBook.controlWebUrl(ClientBook.java:92)
at www.clientbook.cz.ClientBook.access$1(ClientBook.java:90)
at www.clientbook.cz.ClientBook$ClientBookClient.onPageFinished(ClientBook.java:239)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:332)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
這是我的功能controlWebUrl()
private void controlWebUrl(String url) {
//nastavení navigation
if(!url.contains("/index/login") && !url.contains("/index/register") && !url.contains("/index/wait") && !url.contains("/index/active") && !url.contains("/index/forgotpassword")){
mDrawerList.setAdapter(menuListLogin);
login = true;
} else{
mDrawerList.setAdapter(menuList);
login = false;
}
if(url.contains("/index/login")){
setTitle("Přihlášení");
} else if(url.contains("/index/register")){
setTitle("Registrace");
} else if(url.contains("/index/forgotpassword")){
setTitle("Zapomenuté heslo");
} else if(url.contains("/index/wait")){
setTitle("Nepřišel vám e-mail ?");
} else if(url.contains("/index/profile")){
setTitle("Můj profil");
} else if(url.contains("/clients/add")){
setTitle("Přidat klienta");
} else if(url.contains("/clients/list")){
setTitle("Seznam klientů");
} else if(url.contains("/clients/search")){
setTitle("Hledat");
} else if(url.contains("/clients/map")){
setTitle("Mapa klientů");
} else if(url.contains("/clients/show")){
setTitle("Profil klienta");
} else if(url.contains("/clients/edit")){
setTitle("Upravit klienta");
} else if(url.contains("/meetings")){
setTitle("Schůzky");
} else if(url.contains("/forms")){
setTitle("Dotazníky");
} else if(url.contains("/index/account")){
setTitle("Můj účet");
} else if(url.contains("/index/settings")){
setTitle("Nastavení");
} else if(url.contains("/index/search/type/sms")){
setTitle("Hromadná SMS");
} else if(url.contains("/index/search/type/email")){
setTitle("Hromadný E-mail");
} else if(url.contains("/index/search/type/dual")){
setTitle("Hromadná SMS+E-mail");
} else if(url.contains("/index/search/type/history")){
setTitle("Historie Hromadného rozesílání");
} else {
setTitle("ClientBook.cz");
}
}
問題出在哪裏?函數必須有回報?
這是WebViewClient
private class ClientBookClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView webview, String url)
{
if (!loadingFinished) {
redirect = true;
}
loadingFinished = false;
webview.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView webview, String url, Bitmap favicon){
loadingFinished = false;
}
@Override
public void onPageFinished(WebView webview, String url) {
controlWebUrl(mWebView.getUrl());
if(!redirect){
loadingFinished = true;
}
if(loadingFinished && !redirect && findViewById(R.id.connect).getVisibility() == View.GONE){
findViewById(R.id.load_pb).setVisibility(View.GONE);
findViewById(R.id.load_text).setVisibility(View.GONE);
findViewById(R.id.connect).setVisibility(View.GONE);
mWebView.setVisibility(View.VISIBLE);
} else{
if(findViewById(R.id.connect).getVisibility() == View.VISIBLE){
findViewById(R.id.load_pb).setVisibility(View.GONE);
}
redirect = false;
//error = false;
}
}
public void onReceivedError(WebView view, int errorCod,String description, String failingUrl) {
if(errorCod == -1){
mWebView.goBack();
} else if(errorCod == -2){
mWebView.setVisibility(View.GONE);
TextView error_text = (TextView) findViewById(R.id.load_text);
error_text.setText("Neumím pracovat bez internetu..");
error_text.setVisibility(View.VISIBLE);
findViewById(R.id.connect).setVisibility(View.VISIBLE);
}
}
}
你有一個空的指針在ClientBook中的方法controlWebUrl()在92行。 – zgc7009 2014-10-16 15:52:38
你的url或你的mDrawerList是null。 – zgc7009 2014-10-16 17:01:58