腾讯浏览服务

1.地址:https://x5.tencent.com;
2.腾讯浏览服务可以在线打开文档,使用方式:
1)创建布局,添加。
fbsviewRl = findViewById(R.id.fbsviewRl);//用于显示内容的布局。
mTbsReaderView = new TbsReaderView(MainActivity.this, this);//初始化腾讯浏览服务内置视图器
fbsviewRl.addView(mTbsReaderView, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
2)打开文件的方法:
displayFile(Environment.getExternalStorageDirectory().getPath()+ File.separator+”json.txt”);
private void displayFile(String mFileName)
{
Bundle bundle = new Bundle();
bundle.putString(“filePath”, mFileName);
bundle.putString(“tempPath”, Environment.getExternalStorageDirectory().getPath());
boolean result = mTbsReaderView.preOpen(parseFormat(mFileName), false);
if (result) {
mTbsReaderView.openFile(bundle);
}
}
private String parseFormat(String fileName)
{
return fileName.substring(fileName.lastIndexOf(“.”) + 1);
}
3)onDestroy方法中添加结束方法:
@Override
protected void onDestroy() {
super.onDestroy();
if(mTbsReaderView!=null)
{
mTbsReaderView.onStop();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *