应用内跳转: 隐式跳转主要用于打开系统界面这里不做介绍
1.最简单的:
//MainActivity :当前activity
Intent intent = new Intent(MainActivity.this,SdpActivity.class);
//"15710833644" 账号 string类型;
intent.putExtra("phoneNo","15710833333");
startActivity(intent);
或者
Intent intent = new Intent();
intent.setClass(MainSdpActivity.this, SdpActivity.class);
intent.putExtra("phoneNo","15710833333");
startActivity(intent);
SdpActivity中接收参数
phoneNo = getIntent().getStringExtra("phoneNo");
2.可用与应用间的intent 跳转
Intent intent1 = new Intent();
intent1.setComponent(new ComponentName("com.czj.componentnamedemo",
"com.czj.componentnamedemo.SecondActivity"));
startActivity(intent1);
3.URL 跳转
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("zznodesdp://intenttest?phoneNo=18117252660&url=http://211.142.21.249:8080/wechatApp/app/sx-app-release.apk")); startActivity(intent);
接受参数:
Intent intent = getIntent(); Uri data = intent.getData(); String phoneNo = data.getQueryParameter("phoneNo")+";"+data.getQueryParameter("url");
manifest 文件对应的activity需要配置
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
<data
android:scheme="zznodesdp"
android:host="intent"
/>
</intent-filter>