我的 android 应用程序中的另一个问题。当我单击主页按钮时,它会退出应用程序但说Sorry, the application has stopped unexpectedly
我的主页按钮的代码是
ImageView home = (ImageView)findViewById(R.id.home1);
home.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
kalma1.stop();
Intent i =new Intent(Kalma1.this, null);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
}
});
控制台显示以下内容
GC_EXTERNAL_ALLOC freed 1110 objects / 70984 bytes in 77ms
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x4001d800)
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:76)
at android.content.Intent.<init> (Intent.java:2678)
at com.kalmas.Kalma1$5.onClick(Kalma1.java:74)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Sending signal. PID: 368 SIG: 9