如何共享图像通过故意给Facebook [英] how to share image to facebook via intent
本文介绍了如何共享图像通过故意给Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道什么是错在我的code波纹管?为什么在资产图像没有被加载至Facebook分享网页?
I was wondering what is wrong in my code bellow ? why the image in Asset was not loaded to facebook share page?
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///android_asset/images/end_level_10.png"));
share.putExtra(Intent.EXTRA_SUBJECT, "Congratulation! You get A+ with Kid IQ Game.");
share.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=kids.iq.kidsiqpicturesquestion");
startActivity(Intent.createChooser(share, "Congratulation!"));
AP preciate你好心帮!
appreciate for your kindly help!
推荐答案
这是可以共享文件(图像含)从资产通过自定义文件夹的ContentProvider
It is possible to share files (images including) from the assets folder through a custom ContentProvider
您需要扩展的ContentProvider
,在你的清单中注册并实现openAssetFile方法。然后,您可以通过尤里斯评估的资产。
You need to extend ContentProvider
, register it in your manifest and implement the openAssetFile method. You can then assess the assets via Uris.
添加到您的清单。
<provider android:name="yourclass.that.extendsContentProvider"
android:authorities="com.yourdomain.whatever"/>
例如类,
@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
AssetManager am = getContext().getAssets();
String file_name = uri.getLastPathSegment();
if(file_name == null)
throw new FileNotFoundException();
AssetFileDescriptor afd = null;
try {
afd = am.openFd(file_name);
} catch (IOException e) {
e.printStackTrace();
}
return afd;
}
这篇关于如何共享图像通过故意给Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文