在Instagram中使用分享意图。如何知道用户实际共享或取消共享活动?

时间:2018-05-17 06:47:23

标签: android instagram instagram-api

以下是代码;

 Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
 shareIntent.setType("image/*");
 shareIntent.putExtra(Intent.EXTRA_STREAM,  Uri.parse("file://" + finalFile.getAbsolutePath()));
 shareIntent.setPackage("com.instagram.android");
 startActivityForResult(Intent.createChooser(shareIntent, "Share your Photo"),INSTA);

以下onActivityResult不起作用;

if (requestCode==INSTA)
    {
        if (resultCode == Activity.RESULT_OK) {
            // Here you do what you have to do.
            Toast.makeText(getApplicationContext(),"share successful...",Toast.LENGTH_LONG).show();
        }else 
        {
            Toast.makeText(getApplicationContext(),"share unsuccessful...",Toast.LENGTH_LONG).show();
        }

    }

1 个答案:

答案 0 :(得分:2)

你不能

如果您提供的代码无效,则表示 Instagram 在共享图片后不会返回任何结果。但即使他们会返回一个结果(例如,RESULT_OK它并不意味着图片实际上是共享的。)

获取此信息的唯一方法是调用instagram api并检查用户是否在其中发布新照片(例如1-2分钟),但我认为如果不了解用户就不可能: )