本文介绍了如何与其他应用程序共享资产文件夹中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用以下应用程序来共享资产文件夹中的图像
i want to share images inside an assets folder using intent to the following applications
- 视频群聊
- 在线聊天
- viber
- 探戈
- 微信
我已经为whatsapp尝试了此代码,但是它给了我不支持的文件
i have try this code for whatsapp but it given me file not supported
public void share (){
String file = "file:///android_asset/food/apple.png";
Uri filePath = Uri.fromFile(new File("content://com.example.zainabishaqmusa.postemoji/assets/gestures/aok.png"));
final ComponentName name = new ComponentName("com.whatsapp", "com.whatsapp.ContactPicker");
Intent oShareIntent = new Intent();
oShareIntent.setComponent(name);
//oShareIntent.setType("text/plain");
//oShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Website : www.google.com");
oShareIntent.putExtra(Intent.EXTRA_STREAM, filePath);
oShareIntent.setType("image/png");
oShareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Gesture.this.startActivity(oShareIntent);
}
推荐答案
您将需要一个能够共享资产内容的ContentProvider
. 我的StreamProvider
提供了此功能,或者您也可以自己编写.
You would need a ContentProvider
that is capable of sharing content from assets. My StreamProvider
offers this, or you could write your own.
这篇关于如何与其他应用程序共享资产文件夹中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!