一、在一個Activity中啓動另一個Activity(顯示Intent使用)
java
Button button = (Button) findViewById(R.id.startActivity); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(MainActivity.this,AppActivity.class); startActivity(i); } });
二、經過隱式Intent啓動android
<activity android:name=".AppActivity"> <intent-filter> <category android:name="android.intent.category.DEFAULT"></category> <action android:name="org.smzhang.android.activity.intent.action.startActivity"></action> </intent-filter> </activity>
Button button = (Button) findViewById(R.id.startActivity); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent("org.smzhang.android.activity.intent.action.startActivity"); startActivity(i); } });
三、Activity間傳遞參數ide