最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Sharing content in Instagram direct message with Kotlin - Stack Overflow

programmeradmin1浏览0评论

I currently have a method for sharing an image in Instagram stories that works for me, it opens the Instagram app directly with the activity to post a storie:

    private fun shareWithInstagramStories(contentUri: Uri): Intent {
        val intent = Intent("com.instagram.share.ADD_TO_STORY")
        val sourceApplication = context?.getString(R.string.facebook_app_id)
        intent.putExtra("source_application", sourceApplication)
        intent.setDataAndType(contentUri, "image/jpeg")
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
        return intent
    }

I want to do something similar but for Instagram Direct, is there anything similar? I know the Spotify app has a custom share dialog that opens up this direct message activity, but I don't know how they do it. Right now this is it:

  private fun shareWithInstagramDirect(contentUri: Uri): Intent {
        return Intent(Intent.ACTION_SEND).apply {
            type = "image/jpeg"
            putExtra(Intent.EXTRA_STREAM, contentUri)
            `package` = "com.instagramm.android"
            addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
        }
    }

What it does is launch an Instagram dialogue that gives me a choice between Reels, Stories, Direct and Feed, but I would like to launch the direct directly.

发布评论

评论列表(0)

  1. 暂无评论