gpt4 book ai didi

android - Intent 在 snapchat 应用程序上打开与特定用户的聊天

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:02 27 4
gpt4 key购买 nike

我正在尝试查找是否存在任何应用架构,

使用我想与之聊天的特定用户 ID 打开 Snapchat 应用程序(通过 Intent)?

顺便说一句,找到用户ID:

enter image description here

最佳答案

这是唯一对我有用的东西。不幸的是,它增加了让用户选择浏览器或 Snapchat 应用程序的额外步骤。

Intent nativeAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://snapchat.com/add/" + snapchatId));
startActivity(nativeAppIntent);

奇怪的是,URL 方案 snapchat://add/"+ snapchatId 适用于 iOS 但不适用于 Android(它会打开 Android 应用程序,但不会弹出用户)。

编辑:添加intent.setPackage("com.snapchat.android");,它将在没有选择器的情况下打开应用程序。但是添加这意味着您需要用 try/catch 包围所有内容以防止崩溃。

try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://snapchat.com/add/" + snapchatId));
intent.setPackage("com.snapchat.android");
startActivity(intent);
} catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://snapchat.com/add/" + snapchatId)));
}

关于android - Intent 在 snapchat 应用程序上打开与特定用户的聊天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31436060/

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