Eni*_*ing 1 android android-sharing snapchat
我正在我的应用程序中添加共享功能,除了共享到 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
Run Code Online (Sandbox Code Playgroud)
我使用 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>
Run Code Online (Sandbox Code Playgroud)
还有这样的路径:
<paths>
<cache-path name="cache" path="/" />
Run Code Online (Sandbox Code Playgroud)
你能帮我弄清楚是什么问题吗?感谢所有的答案!
某些应用程序(如 Snapchat)使用不明显的方式接受发送的媒体,因此您应该设置为您的意图组件:
intentComponent = ComponentName("com.snapchat.android", "com.snapchat.android.LandingPageActivity")
intent.component = intentComponent
//use component instead of setting package
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
948 次 |
| 最近记录: |