一、跳转其他app入口页写法
1.跳转入口页+数据传递
// com.cgc999.accessory包路径
// MainActivity:对应跳转的Activity类名
// resUrl :String类型
// picUrlList:数组,也可以是对象
ComponentName componentName = new ComponentName(
"com.cgc999.accessory",
"com.cgc999.accessory.MainActivity");
Intent intent = new Intent();
Bundle bundle = new Bundle();
String resurl = "startAccessorySuccess ";
bundle.putString("resUrl", resurl);
String[] picurllist = {"百度", "阿里", "腾讯"};
bundle.putSerializable("picUrlList", picurllist);
intent.putExtras(bundle);
intent.setComponent(componentName);
startActivity(intent);
2.入口页获取跳转app传递数据
public String getResultMessage() {
Intent mIntent = this.getIntent();
String resUrl = mIntent.getStringExtra("resUrl");
String[] picUrlList = (String[]) mIntent.getSerializableExtra("picUrlList");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(resUrl);
if (null != picUrlList) {
for (int i = 0; i < picUrlList.length; i++) {
stringBuffer.append(picUrlList[i]);
}
}
return stringBuffer.toString();
}
二、跳转其他app详情页写法
1.配置详情页mainfest
<activity android:name=".BodyActivity" >
<intent-filter>
<data
android:host="com.cgc999.accessory"
android:path="/cyn"
android:scheme="csd" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
2.跳转
Intent intent = new Intent();
intent.setData(Uri.parse("csd://com.cgc999.accessory/cyn?type=110"));
// intent.putExtra("", "");//这里Intent当然也可传递参数,但是一般情况下都会放到上面的URL中进行传递
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
跨应用跳转与数据传递
本文详细介绍了在Android平台上实现跨应用跳转的方法,包括如何从一个应用跳转到另一个应用的入口页并传递数据,以及如何配置并跳转到特定应用的详情页。通过具体的代码示例,读者可以学习到跳转过程中的Intent使用技巧,以及如何在目标应用中正确接收和解析传入的数据。
1218

被折叠的 条评论
为什么被折叠?



