我使用以下代码打开一个新的 UI:
String name="com.hellocw.exportmsg.mysettings";
Intent intent1 = new Intent(name);
startActivity(intent1);
它在案例二中运行良好,但在案例一中失败了。为什么?谢谢!
案例一
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainPreferenceActivity"
android:label="Settings">
<intent-filter>
<action android:name="com.hellocw.exportmsg.mysettings" />
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
案例二
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainPreferenceActivity"
android:label="Settings">
<intent-filter>
<action android:name="com.hellocw.exportmsg.mysettings" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>