该文章或问题已被删除

Android 可以使用 Native.js 调用系统分享 文件给第三应用 QQ、微信 达到发送文件给朋友

 当应用内,需要把图片或视频或压缩文件等等文件,发给第三方应用时,可以使用Native.js调用系统自带的分享功能来实现.

var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass("android.content.Intent");
var Uri = plus.android.importClass("android.net.Uri");
var File = plus.android.importClass("java.io.File");
var shareIntent = new Intent(Intent.ACTION_SEND);
				
var filePath=plus.io.convertLocalFileSystemURL("img/3.jpg"); //把应用内的文件路径转化为手机绝对路径
				
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath)));
shareIntent.setType("*/*");//此处可发送多种文件
//shareIntent.setType("application/pdf");//只发送pdf文件

main.startActivity(Intent.createChooser(shareIntent,"分享文件"));


点赞 0      收藏 0

0 个评论

正在加载...

这里空空如也,快来补一刀!

加载更多

回答问题或评论文章请先 或者 注册