manifest.xml中的配置:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- 配置mainactivity -->
<activity
android:name="com.ahut.newactivity.MainActivity"
android:label="这个是第一个页面" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 配置testactivity -->
<activity
android:name="com.ahut.newactivity.TestActivity"
android:label="这个是第二个页面" >
<intent-filter>
<action android:name="com.ahut.test1" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
在mainactivity中的代码:
public void click2(View v) {
Intent intent2 = new Intent();
intent2.setAction("com.ahut.test1");
intent2.addCategory("android.intent.category.LAUNCHER");
startActivity(intent2);
}
其他的都是照着视频抄的代码,运行出现:
01-02 10:56:46.773: E/AndroidRuntime(7882): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.ahut.test1 cat=[android.intent.category.LAUNCHER] }
求大神帮忙看看!