为什么它会立即崩溃并说" x一直停止"在代码中声明BufferedReader
时?
这是现在的代码(不是所有内容):
web.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
web.getSettings().setDomStorageEnabled(true);
web.loadUrl("javascript: {" +
"document.getElementsByName('authid')[0].value = '" + ID + "';" +
"document.getElementsByName('authpw')[0].value = '" + PASS
+ "';" + "var submit = document.getElementsByClassName('inputbutton');"
+ "submit[0].click(); };");
}
});
try {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
} catch (IOException e) {
e.printStackTrace();
}
来自LogCat :
E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.kurt.vertretungsplan, PID: 4525
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.kurt.vertretungsplan/de.kurt.vertretungsplan.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream java.net.URL.openStream()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream java.net.URL.openStream()' on a null object reference
at de.kurt.vertretungsplan.MainActivity.onCreate(MainActivity.java:89)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)
你在哪里看到问题?