首页 文章 精选 留言 我的

精选列表

搜索[Spring项目],共10000篇文章
优秀的个人博客,低调大师

android-opencc,中文简繁转换项目 OpenCC 的安卓版

android-opencc基于OpenCC的源代码,通过Android NDK编译并使用JNI调用OpenCC的中文简繁转换。它拥有OpenCC的最新词库,并支持以下转换。 HK2S, Traditional Chinese (Hong Kong Standard) to Simplified Chinese 香港繁體(香港小學學習字詞表標準)到簡體 S2HK, Simplified Chinese to Traditional Chinese (Hong Kong Standard) 簡體到香港繁體(香港小學學習字詞表標準) S2T, Simplified Chinese to Traditional Chinese 簡體到繁體 S2TW, Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體 S2TWP, Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙 T2HK, Traditional Chinese to Traditional Chinese (Hong Kong Standard) 繁體到香港繁體(香港小學學習字詞表標準) T2S, Traditional Chinese to Simplified Chinese 繁體到簡體 T2TW, Traditional Chinese to Traditional Chinese (Taiwan Standard) 繁體臺灣正體 TW2S, Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體 TW2SP, Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙 范例: 滑鼠裡面的矽二極體壞了,導致游標解析度降低。(臺灣常用詞彙) 可以转换成 鼠标里面的硅二极管坏了,导致光标分辨率降低。(大陆常用词汇) 使用方法: //Add a custom repository repositories { ... maven { url 'https://dl.bintray.com/qichuan/maven/' } } // Add the dependency dependencies { ... compile 'com.zqc.opencc.android.lib:lib-opencc-android:0.8.0@aar' } 文章转载自 开源中国社区[http://www.oschina.net]

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

Android项目实战(三十一):异步下载apk文件并安装(非静默安装)

前言: 实现异步下载apk文件 并 安装。(进度条对话框显示下载进度的展现方式) 涉及技术点: 1、ProgressDialog 进度条对话框 用于显示下载进度 2、AsyncTask 异步任务的使用 耗时操作不能再主线程中进行 安卓开发_浅谈AsyncTask 3、File 文件相关操作 将文件的字节数据生成文件 4、自动打开安装应用操作 下载网络apk数据并生成文件之后需要我们去执行这个apk的安装操作(非静默安装) 实现前提: 1、我们下载的apk的url地址 2、文件权限,网络权限 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> //文件操作权限 <uses-permission android:name="android.permission.INTERNET" /> //网络权限 ---------------------------------------------------------------------------------------------------------------------------------------- 实现: 1、创建ProgressDialog对象,初始化操作,开启下载的异步任务 private void showDownloadProgressDialog(Context context) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setTitle("提示"); progressDialog.setMessage("正在下载..."); progressDialog.setIndeterminate(false); progressDialog.setMax(100); progressDialog.setCancelable(false); //设置不可点击界面之外的区域让对话框小时 progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); //进度条类型 progressDialog.show(); String downloadUrl = "http://ac-edNxPKqQ.clouddn.com/800exxxxxxx68ebcefda.apk"; //这里写你的apk url地址 new DownloadAPK(progressDialog).execute(downloadUrl); } 2、下载apk的异步任务 首先看一下整个异步任务的结构 private class DownloadAPK extends AsyncTask<String, Integer, String> { ProgressDialog progressDialog; File file; public DownloadAPK(ProgressDialog progressDialog) { this.progressDialog = progressDialog; } @Override protected String doInBackground(String... params) { //根据url获取网络数据生成apk文件 return null; } @Override protected void onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); // 这里 改变ProgressDialog的进度值 } @Override protected void onPostExecute(String s) { super.onPostExecute(s); //到这里说明下载完成,判断文件是否存在,如果存在,执行安装apk的操作 } } (1)、 局部变量 ProgressDialog 用于显示下载进度 File 根据网络数据生成的apk文件 ProgressDialog progressDialog; File file; (2)、构造方法,将外部的ProgressDialog对象传到异步任务里 public DownloadAPK(ProgressDialog progressDialog) { this.progressDialog = progressDialog; } (3)、进度更新方法,将下载进度现在在对话框中 @Override protected void onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); progressDialog.setProgress(progress[0]); } (4)、下载网络数据生成apk文件的操作 @Override protected String doInBackground(String... params) { URL url; HttpURLConnection conn; BufferedInputStream bis = null; FileOutputStream fos = null; try { url = new URL(params[0]); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(5000); int fileLength = conn.getContentLength(); bis = new BufferedInputStream(conn.getInputStream()); String fileName = Environment.getExternalStorageDirectory().getPath() + "/magkare/action.apk"; file = new File(fileName); if (!file.exists()) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } file.createNewFile(); } fos = new FileOutputStream(file); byte data[] = new byte[4 * 1024]; long total = 0; int count; while ((count = bis.read(data)) != -1) { total += count; publishProgress((int) (total * 100 / fileLength)); fos.write(data, 0, count); fos.flush(); } fos.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } try { if (bis != null) { bis.close(); } } catch (IOException e) { e.printStackTrace(); } } return null; } (5)、文件下载完成后 判断文件是否存在,存在的话要打开安装apk的操作,并关闭进度对话框 不存在的话说明文件下载失败,进行相关提示即可 @Override protected void onPostExecute(String s) { super.onPostExecute(s); openFile(file); //打开安装apk文件操作 progressDialog.dismiss(); //关闭对话框 } (6)、打开apk文件安装apk的操作 private void openFile(File file) { if (file!=null){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); TaskListActivity.this.startActivity(intent); } } 效果图: 完整代码: private void showDownloadProgressDialog(Context context) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setTitle("提示"); progressDialog.setMessage("正在下载..."); progressDialog.setIndeterminate(false); progressDialog.setMax(100); progressDialog.setCancelable(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.show(); String downloadUrl = "http://ac-edNxPKqQ.clouddn.com/80xxxxxxxebcefda.apk"; new DownloadAPK(progressDialog).execute(downloadUrl); } /** * 下载APK的异步任务 */ private class DownloadAPK extends AsyncTask<String, Integer, String> { ProgressDialog progressDialog; File file; public DownloadAPK(ProgressDialog progressDialog) { this.progressDialog = progressDialog; } @Override protected String doInBackground(String... params) { URL url; HttpURLConnection conn; BufferedInputStream bis = null; FileOutputStream fos = null; try { url = new URL(params[0]); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(5000); int fileLength = conn.getContentLength(); bis = new BufferedInputStream(conn.getInputStream()); String fileName = Environment.getExternalStorageDirectory().getPath() + "/magkare/action.apk"; file = new File(fileName); if (!file.exists()) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } file.createNewFile(); } fos = new FileOutputStream(file); byte data[] = new byte[4 * 1024]; long total = 0; int count; while ((count = bis.read(data)) != -1) { total += count; publishProgress((int) (total * 100 / fileLength)); fos.write(data, 0, count); fos.flush(); } fos.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } try { if (bis != null) { bis.close(); } } catch (IOException e) { e.printStackTrace(); } } return null; } @Override protected void onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); progressDialog.setProgress(progress[0]); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); openFile(file); progressDialog.dismiss(); } private void openFile(File file) { if (file!=null){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); TaskListActivity.this.startActivity(intent); } } } 异步下载apk文件并安装 ------------------------------------------------------------------------------------------------------------------------------------------ 注意: 如果是一次性全部获取到网络文件的字节数据,当文件过大的时候会出现OOM的问题。 此方法 实现边下载获取网络文件的字节数据边生成文件的操作。 不用担心OOM 的问题。 其他文件下载操作都可以参考此方法。 学习自 :http://www.cnblogs.com/laujiangtao/ 同学

资源下载

更多资源
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等操作系统。

用户登录
用户注册
修改密码
忘记密码