如何从我的android应用程序将图像共享到Snapchat?
我正在我的应用程序中添加共享功能,除了共享到Snapchat外,其他一切都正常。当我发送“发送”意图Snapchat时,它只会打开自己的相机预览,我的照片会丢失。我尝试了不同的方法,但没有任何帮助。另外,当我通过标准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
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