Android分享Api使用(兼容模式)
来源:互联网 发布:python程序化交易 编辑:程序博客网 时间:2024/06/05 07:53
public class SharingSupport extends Activity { @Override protected void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.sharing_support); } @Override public boolean onCreateOptionsMenu(Menu menu) { ShareCompat.IntentBuilder b = ShareCompat.IntentBuilder.from(this); b.setType("text/plain").setText("Share from menu"); MenuItem item = menu.add("Share"); ShareCompat.configureMenuItem(item, b); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); return true; } public void onShareTextClick(View v) { ShareCompat.IntentBuilder.from(this) .setType("text/plain") .setText("I'm sharing!") .startChooser(); } public void onShareFileClick(View v) { try { // This file will be accessed by the target of the share through // the ContentProvider SharingSupportProvider. FileWriter fw = new FileWriter(getFilesDir() + "/foo.txt"); fw.write("This is a file share"); fw.close(); ShareCompat.IntentBuilder.from(this) .setType("text/plain") .setStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt")) .startChooser(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void onShareMultipleFileClick(View v) { try { // These files will be accessed by the target of the share through // the ContentProvider SharingSupportProvider. FileWriter fw = new FileWriter(getFilesDir() + "/foo.txt"); fw.write("This is a file share"); fw.close(); fw = new FileWriter(getFilesDir() + "/bar.txt"); fw.write("This is another file share"); fw.close(); ShareCompat.IntentBuilder.from(this) .setType("text/plain") .addStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt")) .addStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/bar.txt")) .startChooser(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }}
0 0
- Android分享Api使用(兼容模式)
- Android 微信分享Api使用详解
- Selendroid在Appium中的使用(兼容Android api 17 以下)
- Android官方API文档完整版(分享)
- android 分享 api
- Api-Android分享功能
- Android API 23分享
- android 兼容API的检查
- android 兼容API的检查
- Android使用官方API分享内容到QQ和微信(非第三方集成)
- [Android分享] 隐藏API和Internal包的使用
- IE8兼容模式(兼容模式其实就是使用IE7的显示引擎)打开网页
- 强制IE使用兼容模式
- 强制IE使用兼容模式
- 分享Android API,sdk,adt
- Facebook API使用经验分享
- Android中巧用Java反射机制 :兼容新老版本的SDK、使用私有的API
- [Android]高低API版本兼容之@TargetApi
- 如何修复U盘里的文件
- h264 图像、帧、片、NALU
- parent,son深刻理解this,super关键字
- Linux下查看应用程序库函数API接口的方法
- XMPP协议实现原理介绍
- Android分享Api使用(兼容模式)
- 配置Haproxy日志功能
- json2.js 简析(个人学习)
- runtime 机制
- static关键字以及字符串常量的理解
- ios 根据两个经纬度计算距离
- 黑马程序员学习笔记——排列组合的递归
- 类(小结)
- android控件的对齐方式(转)