android - Instagram 分享问题 : Always I get the message “Unable to load image”

标签 android instagram

我正在开发共享功能

我的 Instagram 分享有问题

这是我的代码:

  • 我正在尝试共享存储在“可绘制”文件夹中的“帐户”图像。这只是一个示例

    try {
        Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareIntent.setType("image/*");
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Uri uri = Uri.parse("android.resource://com.example.swathi.booklender/drawable/account");
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        shareIntent.setPackage("com.instagram.android");
        startActivity(shareIntent);
    }catch (Exception e)
    {
        Toast.makeText(getActivity(),"No Activity available, install instagram",Toast.LENGTH_LONG).show();
        e.printStackTrace();
    } 
    

如何解决这个问题?

最佳答案

不能直接共享drawable

先从drawable创建一个文件然后分享

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
File image = new File(getFilesDir(), "foo.jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
startActivity(Intent.createChooser(shareIntent, "Share image via"));

关于android - Instagram 分享问题 : Always I get the message “Unable to load image” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43583125/

相关文章:

instagram - 如何从 Instagram URL 获取媒体 ID

ios - Instagram 客户端身份验证在重定向后缺少#access_token

java - 使用endpoints.sh生成客户端库不会生成libs JAR

android - 使您的 Android 应用程序的应用程序内购买过程更难破解的最佳实践?

android - MIUI 权限被拒绝 Activity KeyguardLocked

Instagram - 用于过滤日期范围内的图像的 API

像instagram一样的Android照片流布局

ios - 如何处理具有多个 URL 的 UIApplication handleOpenURL

android - android :windowBackground and android:colorBackground? 之间的区别

Android:更改 list 中的 BroadcastReceiver 属性是否可以阻止其在用户更新应用程序时接收广播?