我正在开发共享功能
我的 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/