我们正在关注从应用程序到 Instagram 分享故事的官方文档
https://developers.facebook.com/docs/instagram/sharing-to-stories/
预期的行为是,当我尝试分享故事时,Instagram 应用程序的故事屏幕应该打开,并在意图中发送图像。实际行为是 instagram 应用程序未打开且用户停留在同一屏幕上。
// Define image asset URI and attribution link URL
Uri backgroundAssetUri = "your-image-asset-uri-goes-here;"
String attributionLinkUrl = "https://www.my-aweseome-app.com/p/BhzbIOUBval/";
// Instantiate implicit intent with ADD_TO_STORY action,
// background asset, and attribution link
Intent intent = new Intent("com.instagram.share.ADD_TO_STORY");
intent.setDataAndType(backgroundAssetUri, MEDIA_TYPE_JPEG);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra("content_url", attributionLinkUrl);
// Instantiate activity and verify it will resolve implicit intent
Activity activity = getActivity();
if (activity.getPackageManager().resolveActivity(intent, 0) != null) {
activity.startActivityForResult(intent, 0);
}
Run Code Online (Sandbox Code Playgroud)