------------onCreate中---------
myButton.setOnClickListener(new MyButtonListener());
------------自定义函数---------
class MyButtonListener implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
//this Acrivity to other Activity
intent.setClass(FirstActivity.this, OtherActivity.class);
FirstActivity.this.startActivity(intent);
}
}
intent.putExtra("testString,"123");
在令一个Activity中使用
Intent intent = getIntent();//得到传递过来的Intent.
String testString = intent.getStringExtra("testString");
Uri uri = Uri.parse("smsto:18911892639");
Intent intent = new Intent(Intent.ACTION_SENDTO,uri);
intent.putExtra("sms_body","郎耀亮,我想对你说……");
startActivity(intent);
也就是说不同应用程序之间也可以使用Intent进行调用Activity.