使用action name,举例:
1. 比如建立activity4,我们对它的AndroidManifest.xml修改一下
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.devdiv.activity4"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".activity4"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="devdiv.intent.action.activity4" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
2. 新建一个新工程activity5
启动activity4的方法为
Intent intent = new Intent("devdiv.intent.action.activity4");
startActivity(intent);