从另外一个Android应用程序打开Instagram的应用程序和发送图像的一个标题 [英] Open Instagram app from another android app and send an Image with a Caption

查看:135
本文介绍了从另外一个Android应用程序打开Instagram的应用程序和发送图像的一个标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上找的是从其他应用程序打开Instagram的应用程序和发送图像的标题。 有一些有用的文档这样做iOS中。 ( iPhone钩

What I basically looking for is to open Instagram app from another app and send an Image with a caption. There is some useful documentation to do this in iOS. (iPhone-hooks)

做Instagram的支持iOS中执行Android的自定义操作,如在 iPhone-挂钩的?

Do Instagram support to perform custom actions in Android like in iOS as described in iPhone-hooks?

下面是我的应用程序部分用于执行此任务的当前code。

Below is the current code used in my application to perform this task partially.

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的工作。

None of the above Title, description, Caption 01, Caption 02, Caption 03 worked.

然后我尝试着,

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

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

过,但没有上述还曾。

too, but none of the above worked also.

推荐答案

看着这个问题,特别是到这个答案由Chriskot 的,看起来,自2014年7月的Instagram可以让你做到这一点。

Looking at this question, and in particular to this answer by Chriskot, it looks that since July 2014 Instagram lets you do this.

长话短说

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);

这篇关于从另外一个Android应用程序打开Instagram的应用程序和发送图像的一个标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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