传值:
拨打电话:
Intent intent=new Intent();
intent.putExtra("数据名称", "数据");
intent.setClass(context, 跳转的activity.class);
startActivity(intent);
取值:
Intent intent=getIntent();
String StringE=intent.getStringExtra("数据名称");
打开网页:
Uri uri = Uri.parse("http://www.google.com");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
拨打电话:
Uri uri =Uri.parse("tel:xxxxxx");
Intent it = new Intent(Intent.ACTION_DIAL,uri);
startActivity(it);
调用发短信的程序:
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "TheSMS text");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
activity A:
Intent intent=new Intent();
intent.setClass(A.this, B.class);
Bundle bundle=new Bundle();
String str1="aaaaaa";
bundle.putString("str1", str1);
intent.putExtras(bundle);
startActivityForResult(intent, 0);//这里采用startActivityForResult来做跳转,此处的0为一个依据,可以写其他的值,但一定要>=0
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) { //resultCode为回传的标记,我在B中回传的是RESULT_OK
case RESULT_OK:
Bundle b=data.getExtras(); //data为B中回传的Intent
String str=b.getString("str1");//str即为回传的值
break;
default:
break;
}
}
activity B:
setResult(1, intent); //调用onActivityResult 要写在finish()之前