一、Activity 显式启动 (代码示例):
public class MyActivity extends Activity {
Button buttonStart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonStart = (Button) findViewById(R.id.start);
buttonStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//显示启动
Intent intent = new Intent();
intent.setClass(MyActivity.this, SecondActivity.class);
startActivity(intent);
}
});
}
}...
二、Activity 隐式启动 (代码示例):
public class MyActivity extends Activity {
Button buttonStart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonStart = (Button) findViewById(R.id.start);
buttonStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//隐式启动
Intent intent = new Intent();
intent.setAction("asdf.SecondActivity");
startActivity...
:(太开心)