private void jumpToUrl() {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("https://www.baidu.com/");
intent.setData(content_url);
startActivity(intent);
}
private void jumpToMicroTest() {
ComponentName componentName=new ComponentName("com.lany.screenshot","com.lany.screenshot.MainActivity");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("Version", getSimpleVersionInfo());
intent.putExtra("buildNumber", buildNumber);
startActivity(intent);
}
除了跳转,还可以附带数据,注意在跳转到其他app时,跳转到的app必须在跳转到的界面的manifest文件中定义exported=true,否则无法正常跳转。

本文介绍了如何在Android应用程序内部实现不同组件间的跳转,并演示了如何携带额外的数据进行跳转。此外,还强调了为了成功跳转到其他应用程序,目标应用程序需要在Manifest文件中设置exported属性为true。
869

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



