Android(安卓)各种功能代码收集
16lz
2021-01-26
1.分享图片等文件到单个指定微信好友
1 /** 2 * 分享信息到朋友 3 * 4 * @param file 5 * 假如图片的路径为path,那么file = new File(path); 6 */ 7 private void shareToFriend(File file) { 8 Intent intent = new Intent(); 9 ComponentName componentName = new ComponentName("com.tencent.mm", 10 "com.tencent.mm.ui.tools.ShareImgUI"); 11 intent.setComponent(componentName); 12 intent.setAction(Intent.ACTION_SEND); 13 intent.setType("image/*"); 14 intent.putExtra(Intent.EXTRA_TEXT, "测试微信"); 15 intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 16 startActivity(intent); 17 }
2.分享图片等文件到微信朋友圈
1 /** 2 * 分享信息到朋友圈 3 * 4 * @param file 5 * ,假如图片的路径为path,那么file = new File(path); 6 */ 7 private void shareToTimeLine(File file) { 8 Intent intent = new Intent(); 9 ComponentName componentName = new ComponentName("com.tencent.mm", 10 "com.tencent.mm.ui.tools.ShareToTimeLineUI"); 11 intent.setComponent(componentName); 12 intent.setAction(Intent.ACTION_SEND); 13 intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 14 intent.setType("image/*"); 15 startActivity(intent); 16 }
更多相关文章
- Android(安卓)mdpi ldpi hdpi区别(转)
- Android(安卓)实现ListView异步加载图片
- FFmpeg学习—android 编译libfaac 音频库
- Androd学习笔记—— Android刷新本地相册
- android Error: unterminated entity ref 问题
- ubuntu16.04 Android(安卓)Studio 模拟器无法启动
- Android新浪微博开发(四)主UI的完善
- Anroid图片格式转换程序(winXP+cygwin+opencv+ndk)
- Android调用手机新浪微博客户端分享