Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从我的android应用程序将图像共享到Snapchat?_Android_Android Sharing_Snapchat - Fatal编程技术网

如何从我的android应用程序将图像共享到Snapchat?

如何从我的android应用程序将图像共享到Snapchat?,android,android-sharing,snapchat,Android,Android Sharing,Snapchat,我正在我的应用程序中添加共享功能,除了共享到Snapchat外,其他一切都正常。当我发送“发送”意图Snapchat时,它只会打开自己的相机预览,我的照片会丢失。我尝试了不同的方法,但没有任何帮助。另外,当我通过标准Android共享屏幕进行共享时,Snapchat会成功打开它。这是我的代码: var tempFile = File(filePath) val sharingIntent = Intent(Intent.ACTION_SEND) sharingI

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

 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:

  <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="/" />

你能帮我找出问题所在吗? 谢谢你的回答

某些应用程序(如Snapchat)使用不明显的方式接收发送的媒体,因此您应该设置您的意图组件:

intentComponent = ComponentName("com.snapchat.android", "com.snapchat.android.LandingPageActivity")
intent.component = intentComponent
//use component instead of setting package 
某些应用程序(如Snapchat)使用不明显的方式接收发送的媒体,因此您应该设置为您的意图组件:

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