找不到用于处理Intent的活动com.instagram.share.ADD_TO_STORY [英] No Activity found to handle Intent com.instagram.share.ADD_TO_STORY

查看:164
本文介绍了找不到用于处理Intent的活动com.instagram.share.ADD_TO_STORY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的React Native应用程序中,我们试图让用户根据视图/组件中的选择直接将特定的图像共享到提要或故事中.

In our React Native app, we're trying to have our users share specific images straight to either feed or story depending on a selection within our view/component.

当我们尝试直接使用"com.instagram.share.ADD_TO_FEED"进行共享时,它会以一致的方式完美运行.

When we try to share using "com.instagram.share.ADD_TO_FEED" directly, it works perfectly in a consisten manner.

但是,当尝试直接使用"com.instagram.share.ADD_TO_STORY"进行共享时,会出现以下错误:

However when trying to share using "com.instagram.share.ADD_TO_STORY" directly we get the following error:

未找到可处理意图的活动{act = com.instagram.share.ADD_TO_STORY> typ = image/* flg = 0x10000000 pkg = com.instagram.android(有其他功能)

No Activity found to handle Intent { act=com.instagram.share.ADD_TO_STORY > typ=image/* flg=0x10000000 pkg=com.instagram.android (has extras) }

我们已经使其只能在一个设备上使用(特别是使用Samsung Note 8),但是我们的其他测试设备都弹出该错误.

We've gotten it to work only with one device (specifically using a Samsung Note 8), but our other test devices all have that error pop up.

这是我们的代码:

@ReactMethod
public void shareWithInstagram(String fileName, String base64str, String mode, Callback callback,
        Callback secondCallback) {

    this.callback = callback;

    String type = "image/*";

    File media = saveImage(getReactApplicationContext(), fileName, base64str);

    if (isAppInstalled("com.instagram.android") == false) {
        callback.invoke("Sorry, instagram is not installed in your device.");
    } else {
        if (media.exists()) {
            Intent share = new Intent("com.instagram.share." + mode);
            share.setType(type);
            share.setPackage("com.instagram.android");
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.setVmPolicy(builder.build());
            Uri uri = Uri.fromFile(media);

            share.setDataAndType(uri, type);
            share.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            share.putExtra(Intent.EXTRA_STREAM, uri);
            Activity currentActivity = getCurrentActivity();

            if (currentActivity.getPackageManager().resolveActivity(share, 0) != null) {

                currentActivity.startActivityForResult(share, INSTAGRAM_SHARE_REQUEST);
            } else {
                callback.invoke("Sorry, an error ocurred.");
            }
        } else {
            callback.invoke("Sorry, image could not be loaded from disk.");
        }
    }

}

推荐答案

这可能是由于在Instagram清单中具有动作com.instagram.share.ADD_TO_STORY的活动具有android:enabled="false"而发生的. com.instagram.share.ADD_TO_FEED操作活动没有此内容.

This is probably happening because the activity with the action com.instagram.share.ADD_TO_STORY has android:enabled="false" in Instagram manifest. The com.instagram.share.ADD_TO_FEED action activity does not have this.

如果您尝试共享图库中的图像,则可以看到与故事的共享也不可用.

You can see that sharing to the Story is also not available if you try to share an image from the gallery.

解决方案很简单:您需要在登录后重新启动Instagram .然后它将变为可用.如果用户实际上不使用Instagram,这可能是防止在应用程序选择器中显示多个Instagram动作的Instagram预防措施.

The solution is simple: you need to restart Instagram after you have logged in. Then it will become available. This is probably an Instagram precaution against showing multiple Instagram actions in app chooser if user actually does not use Instagram.

现在,这变得很有趣:

我们的其他测试设备都弹出该错误

our other test devices all have that error pop up

..它发生的原因是,当您在另一台设备上尝试使用它时,只需安装Instagram,登录到测试帐户并开始尝试..,它永远不会起作用,因为您首先需要重新启动Instagram应用程序! :)

..it happens because when you try it on another device, you just install Instagram, log into your testing account and start trying .. and it never works because you first need to restart the Instagram app! :)

这篇关于找不到用于处理Intent的活动com.instagram.share.ADD_TO_STORY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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