【问题标题】:Open Instagram app from another android app and send an Image with a Caption从另一个 Android 应用程序打开 Instagram 应用程序并发送带有标题的图像
【发布时间】:2013-10-10 08:30:37
【问题描述】:

我基本上寻找的是从另一个应用程序打开 Instagram 应用程序并发送带有标题的图像。 在 iOS 中有一些有用的文档可以做到这一点。 (iPhone-hooks)

Instagram 是否支持在 Android 中像在 iOS 中一样执行自定义操作,如 iPhone-hooks 中所述?

以下是我的应用程序中用于部分执行此任务的当前代码。

private void sendImageToIntagram(Activity activity) {
    Intent intent = activity.getPackageManager().getLaunchIntentForPackage("com.instagram.android");
    if (intent != null) {
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.setPackage("com.instagram.android");
        String imagePath = ImageUtil.getProcessedImage().getAbsolutePath();
        try {
            shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(activity.getContentResolver(), imagePath, "Title", "Description")));
            // shareIntent.putExtra(Intent.EXTRA_TITLE,  "Caption 01");
            // shareIntent.putExtra(Intent.EXTRA_TEXT,   "Caption 02");
            // shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Caption 03");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        shareIntent.setType("image/jpeg");
        activity.startActivity(shareIntent);
    } else {
        // bring user to the market to download the app.

        intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("market://details?id=" + "com.instagram.android"));
        activity.startActivity(intent);
    }
}

以上标题、描述、标题 01、标题 02、标题 03 均无效。

然后我尝试了,

shareIntent.setAction(Intent.ACTION_SEND); --> shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);

和,

shareIntent.setType("image/jpeg");
shareIntent.setType("image/*");
shareIntent.setType("*/*"); 

也是,但以上都不起作用。

【问题讨论】:

    标签: android instagram


    【解决方案1】:

    看看 this question,尤其是 Chriskot 的 this answer,看起来自 2014 年 7 月以来,Instagram 允许您这样做。

    长话短说

    Intent instagram = new Intent(android.content.Intent.ACTION_SEND);  
    instagram.setType("image/*");
    instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
    instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
    instagram.setPackage(instagramPackageName);   
    startActivity(instagram);
    

    【讨论】:

      【解决方案2】:

      简答,不。

      Instagram 没有相当于 iPhone-hooks 的 Android 设备。

      他们确实支持ACTION_SEND,但只考虑到Intent.EXTRA_STREAM

      除非在过去 4 个月中发生了一些变化(我对此表示怀疑),否则这个人从他们的 AndroidManifest.xml 中获取了一个存根,您可以通过查看他们只关心 @987654325 的 intent catcher 活动来假设@。

      所以目前,除了实际图像之外,您不能发送任何其他数据。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多