白板
本指南分布说明在您的应用中添加白板功能,为文档和图片添加注释。
在进一步讨论之前,确定您已经注册了您的应用程序与BeTalk。
1. 工作区设置
请参照之前会议中第1步
2. 更新AndroidMaifest.xml
请参照之前会议中第2步
3. 实现登录/登出功能
请参照之前会议中第3步
4. 创建注释
要使用白板API进行批注,首先要得到BTClipManager的一个实例
获取实例
static publicBTClipManagergetInstance();
得到BeTalk标注管理器的一个实例。
示例代码:
BTClipManager clipMgr = BTClipManager.getInstance();
创建注解文档和图片
Public void annotateOnLocalFiles(final List<String> filePath, final OnBTClipListener listener);
在文件(文档,图片等)上添加注释,让用户在应用中保存并分享注释文件。
参数:
名称 | 描述 |
filePath | 本地设备中文件的路径 |
listener | 监听批注事件。请查看OnBTClipListener了解详细信息 |
Unauthorized | 用户没有成功初始化 |
AnnotationIsInProgress | 另一注释正在进行中 |
InvalidParameter | 输入参数是无效的 |
例:
try {
BTClipManager.getInstance().annotateOnLocalFiles(Arrays.asList(path1), this);
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidParameter e) {
e.printStackTrace();
} catch (AnnotationIsInProgress e) {
annotationInProgress();
} catch (Unauthorized e) {
unauthorized();
}
注:单个文件大小限制为100M。
在远程文件上创建注释
要用BeTalk注释远程文件,首先要创建BTClipManager实例,并调用API。
public void annotateWithRemoteFiles (final OnBTClipListener listener)
例:
try {
BTClipManager.getInstance().annotateWithRemoteFiles(this);
} catch (AnnotationIsInProgress e) {
annotationInProgress();
} catch (Unauthorized e) {
unauthorized();
}
回调:
public void onAnnotatePrepareSuccess(String binderID, String token)
监听到回调后,调用此API设置远程文件ID:
void setAnnotateRemoteFileIDs (List<String> fileUniqueIDArray)
通过REST API将文件上传到BeTalk服务器上。
String path1 = f1.getAbsolutePath();
String path2 = f2.getAbsolutePath();
String uuid1 = UUID.randomUUID().toString();
String uuid2 = UUID.randomUUID().toString();
String url1 = String.format("https://www.BeTalk.com/board/%s/%s?type=original&client_uuid=%s&t=%s", binderID, "file1.pdf", uuid1, path1);
String url2 = String.format("https://www.BeTalk.com/board/%s/%s?type=original&client_uuid=%s&t=%s", binderID, "file2.pdf", uuid2, path2);
BTClipManager.getInstance().setAnnotateRemoteFileIDs(Arrays.asList(uuid1, uuid2));
// Upload the file via rest API
如果上传出现错误,调用API来重置界面。
public void uploadAnnotateRemoteFilesFilesFailed()
注:
1. 单个文件大小限制为100M。
2. setAnnotateRemoteFileIDs()应在上传之前应调用,否则会错过一些服务器进程,导致不能记录。