Xamarin表格不能将图片分享到Instagram故事 [英] Xamarin Forms can't share image to Instagram stories

查看:57
本文介绍了Xamarin表格不能将图片分享到Instagram故事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

事实上,我是使用这个选项将故事分享到Instagram的,该选项允许分享到每个Instagram选项,但现在我发现错误恰恰发生在我要分享到Instagram故事的时候。当我选择该选项时,会出现一个黑屏,没有我之前收费的图像,但只有在故事中才会出现这种情况,Feed和Direct可以完美地工作。

// Create the new Intent using the 'Send' action.
             Intent share = new Intent(Intent.ActionSend);

             // Add the URI to the Intent.
             share.PutExtra(Intent.ExtraStream, Uri.Parse("file://" + mediaPath));

             // Set the MIME type
             share.SetType("image/jepg");
             share.SetPackage("com.instagram.android");

             Xamarin.Forms.Forms.Context.StartActivity(Intent.CreateChooser(share, "Share image"));
             result = true;

按照文档操作:

https://developers.facebook.com/docs/instagram/sharing-to-stories

我可以打开Instagram故事编辑器,但我看不到照片,它仍然是黑色的...

 Intent share = new Intent("com.instagram.share.ADD_TO_STORY");
 Uri backgroundAssetUri = Uri.Parse("file://" + ruta);
 share.SetDataAndType(backgroundAssetUri, "image/jepg");
 share.SetFlags(ActivityFlags.GrantReadUriPermission);
    
 Xamarin.Forms.Forms.Context.StartActivity(Intent.CreateChooser(share, "Share image"));

有人能帮帮我吗?

推荐答案

我找到了替代解决方案:

Uri backgroundAssetUri = Uri.Parse("file://" + ruta);
String sourceApplication = "...";
        
Intent share = new Intent("com.instagram.share.ADD_TO_STORY");
share.PutExtra("source_application", sourceApplication);
        
share.SetType("image/jepg");
share.PutExtra("interactive_asset_uri", backgroundAssetUri);
share.PutExtra("top_background_color", "#F5F5F5");
share.PutExtra("bottom_background_color", "#FFFFFF");
share.PutExtra(Intent.ExtraStream, backgroundAssetUri);
        
var activity = Xamarin.Forms.Forms.Context.GetActivity();
activity.GrantUriPermission("com.instagram.android", backgroundAssetUri, ActivityFlags.GrantReadUriPermission);
if (activity.PackageManager.ResolveActivity(share, 0) != null)
{
  activity.StartActivityForResult(share, 0);
}

我认为Instagram和背景的图像有问题,因为这是我找到的将图像共享到Instagram故事的唯一方法,只能使用贴纸。

这篇关于Xamarin表格不能将图片分享到Instagram故事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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