Android分享操作
2016-06-21 16:41
239 查看
本文来源http://wiki.jikexueyuan.com/project/android-training-geek/building-content-sharing.html
使用 intent,必须指定要触发的 Actions,例如:ACTION_SEND
发送简单数据 actions:Intent.ACTION_SEND
发送二进制内容
发送多块内容:Intent.ACTION_SEND_MULTIPLE
给 ActionBar 增加分享功能
1、更新菜单
![](http://img.blog.csdn.net/20160621191941599)
在调试 app 时会出现问题:
![](http://img.blog.csdn.net/20160621192014664)
将注释行改为下面的一行代码就行了
分享文件:
建立文件分享
指定一个 FileProvider,在 Manifest 中加入标签,指定 FileProvider,Authority以及xml文件名
指定共享目录路径
分享文件
接收文件请求思路:AActivity 使用 startActivityForResult()来启动选择文件的 BActivity,选中后返回选择文件的 ContentURI。
创建一个选择文件的 Activity
在代码中定义文件选择 Activity
响应一个文件的选择
为文件授权
与请求应用共享文件,传递带 content uri的 Intent 给 setResult()
请求分享文件
客户端向其他 app(服务端)请求
服务端返回 content URI 的 Intent
得到 URi,使用 FileDescriptor 读取文件
使用 intent,必须指定要触发的 Actions,例如:ACTION_SEND
发送简单数据 actions:Intent.ACTION_SEND
发送二进制内容
发送多块内容:Intent.ACTION_SEND_MULTIPLE
给 ActionBar 增加分享功能
1、更新菜单
在调试 app 时会出现问题:
将注释行改为下面的一行代码就行了
建立文件分享
指定一个 FileProvider,在 Manifest 中加入标签,指定 FileProvider,Authority以及xml文件名
指定共享目录路径
分享文件
接收文件请求思路:AActivity 使用 startActivityForResult()来启动选择文件的 BActivity,选中后返回选择文件的 ContentURI。
创建一个选择文件的 Activity
在代码中定义文件选择 Activity
响应一个文件的选择
为文件授权
与请求应用共享文件,传递带 content uri的 Intent 给 setResult()
请求分享文件
客户端向其他 app(服务端)请求
服务端返回 content URI 的 Intent
得到 URi,使用 FileDescriptor 读取文件
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories