我试图访问中的编辑文本,onNewIntent()
但它向我抛出了空指针异常。
例外 :
10-01 13:20:03.516: E/AndroidRuntime(18170): FATAL EXCEPTION: main
10-01 13:20:03.516: E/AndroidRuntime(18170): java.lang.NullPointerException
10-01 13:20:03.516: E/AndroidRuntime(18170): at com.iween.exampleTest.FirstPage.onNewIntent(FirstPage.java:177)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1155)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2279)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread.performNewIntents(ActivityThread.java:2292)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2301)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread.access$1400(ActivityThread.java:149)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.os.Looper.loop(Looper.java:153)
10-01 13:20:03.516: E/AndroidRuntime(18170): at android.app.ActivityThread.main(ActivityThread.java:4987)
10-01 13:20:03.516: E/AndroidRuntime(18170): at java.lang.reflect.Method.invokeNative(Native Method)
10-01 13:20:03.516: E/AndroidRuntime(18170): at java.lang.reflect.Method.invoke(Method.java:511)
10-01 13:20:03.516: E/AndroidRuntime(18170): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
10-01 13:20:03.516: E/AndroidRuntime(18170): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-01 13:20:03.516: E/AndroidRuntime(18170): at dalvik.system.NativeStart.main(Native Method)
onNewItent 的代码
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
edit1.getText().clear();
}
注销代码
clickToLogout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(Home.this,
Firstpage.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});