gpt4 book ai didi

Android Intent 在设备上使用亚马逊应用程序而不是浏览器来查看项目

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:16:31 24 4
gpt4 key购买 nike

在我的 Android 应用程序中,我有一个带有 Amazon.com 产品背景图片的按钮(比方说一件衬衫或其他东西),点击后我希望它在亚马逊应用程序 (com.amazon.mShop) 中打开.android) 如果已经安装而不是在浏览器中,如果应用程序未安装则在浏览器中。

我已经能够找到如何添加到特定亚马逊客户端应用程序的深层链接,但找不到如何链接到可以通过亚马逊应用程序打开的特定项目。

目前,我的点击监听器通过执行以下操作在浏览器中打开:

b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(urlOfItemOnAmazonSite));
startActivity(intent);
}
})

最佳答案

Amazon 开发人员的主页可能是这个答案的最佳位置。这可能是一个好的开始:https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/deeplink#Link%20Configuration .他们在这里解释了如何构建您需要用来设置 Intent 数据的 Uri

当然,您可能需要小心,将 startActivity 包裹在 try/catch 中,以防未安装 Amazon 并抛出 ActivityNotFoundException

关于Android Intent 在设备上使用亚马逊应用程序而不是浏览器来查看项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21059641/

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