打算在手套应用程序上与特定用户打开聊天 [英] Intent to open a chat with a specific user on snapchat app

查看:202
本文介绍了打算在手套应用程序上与特定用户打开聊天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to find if there is any app schema,

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

to open the Snapchat app (via Intent) with a specific userID that I want to chat with?

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

BTW, to find the userID:

推荐答案

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

This the only thing that works for me. Unfortunately, it adds the extra step of making the user choose the browser or Snapchat app.

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

奇怪的是,URL方案snapchat://add/" + snapchatId在iOS上有效,但在Android上无效(打开Android应用,但不会弹出用户).

Oddly enough, the URL scheme snapchat://add/" + snapchatId works on iOS but not on Android (it opens the Android app, but does not pop up the user).

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

EDIT: Add intent.setPackage("com.snapchat.android"); and it will open the app without the chooser. But adding this means you will need to surround everything with a try/catch to prevent a crash.

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)));
}

这篇关于打算在手套应用程序上与特定用户打开聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆