首页 文章 精选 留言 我的

精选列表

搜索[mozilla浏览器套件],共10000篇文章
优秀的个人博客,低调大师

Android使用TBS浏览器加载pdf等文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qingfeng812/article/details/79077350 项目结构 技术方案 TBS的其它优点,可以自行搜索网上其它资料,很多。 加载文件核心类是 TbsReaderView,腾讯文档没有写,所以需要查找网上资料。 TBS目前只支持加载本地文件。所以远程文件需要先下载,后用TBS加载文件显示。 负责加载和显示文件的界面,离开本界面之后务必需要销毁,否则再次加载文件无法加载成功,会一直显示加载文件进度条。 关键代码: mTbsReaderView.onStop();//销毁界面的时候一定要加上,否则后面加载文件会发生异常。 完整项目源码 package com.yifeng.sample.tbs; import android.app.DownloadManager; import android.app.DownloadManager.Request; import android.content.Intent; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.RelativeLayout; import com.tencent.smtt.sdk.TbsReaderView; import com.tencent.smtt.sdk.TbsReaderView.ReaderCallback; import java.io.File; public class MainActivity extends AppCompatActivity implements ReaderCallback { private TbsReaderView mTbsReaderView; private Button mDownloadBtn; private DownloadManager mDownloadManager; private long mRequestId; private DownloadObserver mDownloadObserver; private String mFileUrl = "http://www.beijing.gov.cn/zhuanti/ggfw/htsfwbxzzt/shxfl/fw/P020150720516332194302.doc"; private String mFileName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTbsReaderView = new TbsReaderView(this, this); mDownloadBtn = (Button) findViewById(R.id.btn_download); RelativeLayout rootRl = (RelativeLayout) findViewById(R.id.rl_root); rootRl.addView(mTbsReaderView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mFileName = parseName(mFileUrl); if (isLocalExist()) { mDownloadBtn.setText("打开文件"); } if (isLocalExist()) { mDownloadBtn.setVisibility(View.GONE); displayFile(); } else { startDownload(); } } @Override public void onBackPressed() { startActivity(new Intent(MainActivity.this,IndexActivity.class)); finish();//不关掉此界面,之后加载文件会无法加载 } public void onClickDownload(View v) { // if (isLocalExist()) { // mDownloadBtn.setVisibility(View.GONE); // displayFile(); // } else { // startDownload(); // } } private void displayFile() { Bundle bundle = new Bundle(); bundle.putString("filePath", "/storage/emulated/0/uu/HTTP权威指南.pdf"); bundle.putString("tempPath", Environment.getExternalStorageDirectory().getPath()); boolean result = mTbsReaderView.preOpen(parseFormat("HTTP权威指南.pdf"), false); if (result) { mTbsReaderView.openFile(bundle); } } private String parseFormat(String fileName) { return fileName.substring(fileName.lastIndexOf(".") + 1); } private String parseName(String url) { String fileName = null; try { fileName = url.substring(url.lastIndexOf("/") + 1); } finally { if (TextUtils.isEmpty(fileName)) { fileName = String.valueOf(System.currentTimeMillis()); } } return fileName; } private boolean isLocalExist() { return getLocalFile().exists(); } private File getLocalFile() { return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), mFileName); } private void startDownload() { mDownloadObserver = new DownloadObserver(new Handler()); getContentResolver().registerContentObserver(Uri.parse("content://downloads/my_downloads"), true, mDownloadObserver); mDownloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mFileUrl)); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mFileName); request.allowScanningByMediaScanner(); request.setNotificationVisibility(Request.VISIBILITY_HIDDEN); mRequestId = mDownloadManager.enqueue(request); } private void queryDownloadStatus() { DownloadManager.Query query = new DownloadManager.Query().setFilterById(mRequestId); Cursor cursor = null; try { cursor = mDownloadManager.query(query); if (cursor != null && cursor.moveToFirst()) { //已经下载的字节数 int currentBytes = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); //总需下载的字节数 int totalBytes = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)); //状态所在的列索引 int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); Log.i("downloadUpdate: ", currentBytes + " " + totalBytes + " " + status); mDownloadBtn.setText("正在下载:" + currentBytes + "/" + totalBytes); if (DownloadManager.STATUS_SUCCESSFUL == status && mDownloadBtn.getVisibility() == View.VISIBLE) { mDownloadBtn.setVisibility(View.GONE); mDownloadBtn.performClick(); } } } finally { if (cursor != null) { cursor.close(); } } } @Override public void onCallBackAction(Integer integer, Object o, Object o1) { } @Override protected void onDestroy() { super.onDestroy(); mTbsReaderView.onStop(); if (mDownloadObserver != null) { getContentResolver().unregisterContentObserver(mDownloadObserver); } } private class DownloadObserver extends ContentObserver { private DownloadObserver(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange, Uri uri) { Log.i("downloadUpdate: ", "onChange(boolean selfChange, Uri uri)"); queryDownloadStatus(); } } }

优秀的个人博客,低调大师

haproxy根据客户端浏览器进行跳转

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 根据手机端 acliphonehdr_sub(user-agent)-iiphone redirectprefix if iphone aclandroidhdr_sub(user-agent)-iandroid redirectprefix if android 根据访问后缀 acltest_picpath_end.gif.png.jpg.css.js use_backendnginxpools if test_pic 根据访问开始路径来匹配 acltest_staticpath_beg /html/ aclhd_domhdr(Host)-i test .com -i忽略大小写 hdr是函数 methodhttp方法 req_ver请求版本 resp_ver响应版本 statushttp状态 url精确匹配url url_reg正则匹配 url_dir斜线之间 url_dom斜线之间或点之间 在haproxy匹配的时候根据use_backend先后顺序进行匹配 Haproxy健康检查方式 1.基于端口的健康检查方式 checkport80 2.基于http的 head 的ipurl健康检查方式 optionhttpchkHEEAD /health .txtHTTP /1 .0 serverweb1192.168.1.2:80maxconn20480weight8checkinter3000fall2rise2 3.基于http的get的健康检查方式 optionhttpchkGET /health .txt 4.基于具体业务域名的URL健康检查 optionhttpchkHEAD /index .jspHTTP /1 .1\r\nHost: optionhttpchkGET /index .jspHTTP /1 .1\r\nHost:www. test .com haproxy中backup参数的使用 本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1689112

优秀的个人博客,低调大师

浏览器都能做人脸检测了?

Shape Detection API 的发布已经有一些时日,其主要的提供的能力是给予前端直接可用的特征检测的接口(包括条形码、人脸、文本检测)。本文将简单的对其进行介绍,对前端进行人脸检测进行普适性的讲解。(本文不讲算法~望轻拍) 1 背景与场景 人脸检测(Face Detection)算是老生常谈的课题了,在诸多行业应用广泛,例如金融、安防、电子商务、智能手机、娱乐图片等行业。其中涉及的技术也在不断的演变,下面简要介绍几种思路: 基于特征的人脸检测 例如opencv中内置了基于Viola-Jones目标检测框架的Harr分类器,只需要载入一个配置文件(haarcascade_frontalface_alt.xml)就能直接调用detectObject去完成检测过程,同时也支持其他特征的检测(如鼻子、嘴巴等)。 基于学习的人脸检测,其实也

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册