gpt4 book ai didi

android - "setComponent"和 "setClassName"在发送 intent 时有什么区别?

转载 作者:行者123 更新时间:2023-11-29 01:16:46 33 4
gpt4 key购买 nike

在我自己的 Android 应用中,我试图显式启动一个外部应用的组件。

Intent i = new Intent();
Uri uri = Uri.parse("http://0.0.0.1");
i.setData(uri);
i.setComponent(new ComponentName("other.app.android","other.app.android.Activity1"));
startActivity(i);

我可以将 i.setComponent(...) 替换为 i.setClassName("other.app.android", other.app.android.Activity1") ?请告诉我它们之间的区别。

最佳答案

是的,你可以做到。在内部 setClassName(String, String) 创建一个 new ComponentName(String, String)

public Intent setClassName(String packageName, String className) {
mComponent = new ComponentName(packageName, className);
return this;
}

关于android - "setComponent"和 "setClassName"在发送 intent 时有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39045340/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com