示例app效果:
参考: 示例
- 复制
lib_fileviewer
模块,加入到project - App中build.gradle中加入以下配置:
ndk {
// 此处必须设置为 armeabi ,TBS 文件浏览不支持其他类型
abiFilters "armeabi"
}
- TBS初始化(在Application中):
QbSdk.initX5Environment(getApplicationContext(), new QbSdk.PreInitCallback() {
@Override
public void onCoreInitFinished() {
Log.d(TAG, "onCoreInitFinished");
}
@Override
public void onViewInitFinished(boolean initResult) {
Log.e(TAG, "onViewInitFinished" + initResult);
}
});
- 查看文件统一入口:
Uri uri = Uri.fromFile(new File(filePath));
FileViewer.viewFile(context,uri)
- 直接使用mupdf查看:
FileViewer.viewPDFWithMuPDFByPath(Context context, String filePath)
或:
FileViewer.startMuPDFActivityByUri(Context context, Uri documentUri)
- 直接使用TBS查看word文档:
TBSFileViewActivity.viewFile(context, filePath);
- office文件无法查看(TBS初始化失败),可以查看这个文档:无法加载x5内核的解决方案.doc
版本: v1.11.1
介绍: MuPDF is an open source software framework for viewing and converting PDF, XPS, and E-book documents. There are viewers for various platforms, several command line tools, and a software library for building tools and applications.
项目地址: https://mupdf.com/docs/
Android 文档: https://mupdf.com/docs/android-sdk.html
简介: web内核