gpt4 book ai didi

android - 从链接打开安卓应用

转载 作者:行者123 更新时间:2023-11-29 02:28:24 25 4
gpt4 key购买 nike

我知道通用链接,但这不是我想做的事情。使用通用链接,我必须定义一些 url 架构,当我尝试在浏览器中打开它时(单击指向该 url 的链接),它会询问我是否要打开该应用程序。如果这不是真的,请纠正我。我想通过 app-name:{data goes here} 或只是简单地通过 app-name: 打开应用程序(app-名称是我想在某处定义的名称)。不确定如何调用此链接?现在我可以通过不同的名称打开该应用程序,但不确定它的定义位置。试图更改包名称,因为我认为它是从那里自动生成的,但没有成功。该应用程序是用 Cordova 编写的,也许有一些限制,我不知道。但如果我知道这种链接名称就好了!当然,如果您能提供更多有关如何使用 Cordova 实现这一点的信息,那就太棒了!

最佳答案

如果你想从另一个应用程序打开一个应用程序,只需使用这个

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.anotherapp");
if (launchIntent != null) {
startActivity(launchIntent);//null pointer check in case package name was not found
}

如果你想从一些网址打开你需要这个,它被称为“深度链接”阅读此 https://developer.android.com/training/app-links/deep-linking

 <intent-filter>
<action android:name="android.intent.action.VIEW"></action>

<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>

<data
android:host="www.my.app.com"
android:path="launch"
android:scheme="http"></data>
</intent-filter>
With the email link set as http://www.my.app.com/launch.

如果您需要在您的应用中从 webView 打开您的应用页面,您只需创建从 WebViewClient 扩展的新 WebViewClient 并处理您的 url那里

关于android - 从链接打开安卓应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50923657/

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