Java 打开instagram的故事页面共享图像或视频

Java 打开instagram的故事页面共享图像或视频,java,android,Java,Android,我想在instagram故事中分享我的照片。现在我可以像这样轻松地打开istagram,但这段代码显示了我们共享照片的页面。 我不想要这个,我只想打开instagram的故事页面 以下是此代码: try { Intent sharingIntent = new Intent(Intent.ACTION_SEND); File media = new File(path); Uri screenshotUri = Uri.fromFile(media); sharingIntent.set

我想在instagram故事中分享我的照片。现在我可以像这样轻松地打开istagram,但这段代码显示了我们共享照片的页面。 我不想要这个,我只想打开instagram的故事页面

以下是此代码:

try {
 Intent sharingIntent = new Intent(Intent.ACTION_SEND);
 File media = new File(path);
 Uri screenshotUri = Uri.fromFile(media);
 sharingIntent.setType("image/*");
 sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
 sharingIntent.setPackage("com.instagram.android");
 startActivity(sharingIntent);
} catch (Exception e) {
 e.printStackTrace();
 Toast.makeText(SavedActivity.this, "برنامه اینستاگرام یافت نشد.", Toast.LENGTH_LONG).show();

}
可以直接分享到instagram的故事中吗?

这是不可能的(更不用说坏习惯了)

您只能指定哪些应用程序可以处理您的意图,而不能在收到该意图后指定它们如何处理该意图

在代码库(即
“com.instagram.android”
)中硬编码要发送到的应用程序包也是不好的做法。以及建议您使用标准的“选择器”模式来共享照片。在这种情况下,用户将决定与哪个应用程序共享照片

Intent share = new Intent(Intent.ACTION_SEND);
share.setType(type);

File media = new File(mediaPath);
Uri uri = Uri.fromFile(media);

share.putExtra(Intent.EXTRA_STREAM, uri);

if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(Intent.createChooser(share, "Share to"));
} else {
    Toast.makeText(this, "No application to share with", Toast.LENGTH_SHORT).show();
}
除非这是一个个人项目(它不会进入谷歌游戏商店),否则我建议你坚持以上模式

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    Uri screenshotUri = Uri.parse(String.valueOf(dest));
    sharingIntent.setType("video/*");
    sharingIntent.setPackage("com.instagram.android");
    sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
    startActivity(Intent.createChooser(sharingIntent, "Share Video "));

我希望它能帮助一些人。

我知道,只是我想知道有没有可能直接打开instagram story?@user7908469除非instagram已经在他们的端部实现了一些东西来实现这一点,并且根据我从他们的文档中读到的,他们没有。不过,现在我想起来了,他们可能已经实现了,在这种情况下,您应该能够在
ACTION\u视图中使用故事的URL
intent;这将链接到应用程序中的故事(如果已安装)。