07-18 04:48:22.465: E/AndroidRuntime(19105): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.liamwli.fa.yearbook/com.liamwli.fa.yearbook.Home}: java.lang.NullPointerException
那是我得到的错误。
我在清单中定义了 Home 类:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.liamwli.fa.yearbook"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<intent-filter>
<action android:name="com.liamwli.fa.yearbook.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
当我在主要活动中添加 putExtras 行时,它才开始这样做:
enter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
myname = name.getText().toString();
Intent i = new Intent("com.liamwli.fa.yearbook.HOME");
i.putExtra("myname", myname);
startActivity(i);
}
});
那么,任何人都可以解释发生了什么吗?