如何从我的Android应用程序将图像共享到Snapchat? [英] How to share image to Snapchat from my android app?

查看:416
本文介绍了如何从我的Android应用程序将图像共享到Snapchat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中添加了共享功能,除了与Snapchat共享外,其他所有功能都正常运行。当我发送发送意图时,Snapchat仅打开其自己的相机预览,而我的照片丢失。我尝试了不同的方法,但没有任何帮助。同样,当我通过标准的Android共享屏幕进行共享时,Snapchat会成功打开它。所以这是我的代码:

I'm adding share feature in my app, and everything works fine except sharing to Snapchat. When I send "SEND" intent Snapchat only opens it own camera preview and my picture is lost. I tried different things, but nothing helps. Also when I share via standard Android sharing screen, Snapchat successfully opens it. So here is my code:

 var tempFile = File(filePath)
        val sharingIntent = Intent(Intent.ACTION_SEND)
        sharingIntent.type = "image/jpg"
        sharingIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
        val image = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, tempFile)
        sharingIntent.putExtra(Intent.EXTRA_STREAM, image)
        sharingIntent.`package` = "com.snapchat.android"
        return sharingIntent

我使用FileProvider:

I use FileProvider :

  <provider
        android:name="android.support.v4.content.FileProvider"
        android:grantUriPermissions="true"
        android:exported="false"
        android:authorities="${applicationId}">

        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_provider_path"/>
    </provider>

这样的路径:

<paths>
<cache-path name="cache" path="/" />

您能帮我找出问题所在吗?
感谢您的所有回答!

Can you help me please to figure out what is the problem? Thanks for all the answers!

推荐答案

某些应用程序(例如Snapchat)使用接受已发送媒体的明显方法,因此应将其设置为Intent组件:

Some app (like Snapchat) use unobvious way of accepting sent Media, so you should set to your intent component:

intentComponent = ComponentName("com.snapchat.android", "com.snapchat.android.LandingPageActivity")
intent.component = intentComponent
//use component instead of setting package 

这篇关于如何从我的Android应用程序将图像共享到Snapchat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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