2012年11月18日

摘要: 1.计算文件大小,并按**B,*KB,**MB,**GB格式返回字符串/** * 文件大小格式转换 * @param fileS 文件大小 * @return 文件大小 */ public static String FormetFileSize(long fileS) { // 转换文件大小 DecimalFormat df = new DecimalFormat("#.00"); String fileSizeString = ""; if (fileS < 1024) {... 阅读全文
posted @ 2012-11-18 11:58 vizhen 阅读(190) 评论(0) 推荐(0)

2012年7月11日

摘要: /** * 查询系统是否安装packageName的apk */ public static boolean isInstallApk(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); java.util.List<PackageInfo> apps = new ArrayList<PackageInfo>(); apps = packageManager.getInstalledPackage... 阅读全文
posted @ 2012-07-11 10:50 vizhen 阅读(221) 评论(0) 推荐(0)

2012年7月7日

摘要: 1 public static String getTopActivityComponet(Context context) 2 { 3 try { 4 ActivityManager am = (ActivityManager) context 5 .getSystemService(Context.ACTIVITY_SERVICE); 6 ComponentName cn = am.getRunningTasks(1).get(0).topActivity; 7 re... 阅读全文
posted @ 2012-07-07 17:24 vizhen 阅读(466) 评论(0) 推荐(0)

2012年6月18日

摘要: 获取txt文档的编码方式,亲测可用。public static String getCharset(File file) { String charset = "GBK"; // 默认编码 byte[] first3Bytes = new byte[3]; try { boolean checked = false; BufferedInputStream bis = new BufferedInputStream( new FileInputStream(file)); ... 阅读全文
posted @ 2012-06-18 10:54 vizhen 阅读(434) 评论(0) 推荐(0)

2011年11月25日

摘要: 虽然Linux下面没有有道,但是我还是最喜欢使用命令:dict,查单词,很方便。每次遇到生词就调出终端,敲下这个命令,很是方便。 安装方法: 1.安装客户端sudo apt-get install dict 2.安装字典包英英字典包:sudo apt-get install dict-gcide英汉字典包(两个比较简单的字典包):sudo apt-get install dict-xdict dict-stardic这样就可以直接在终端里面查单词了,命令就是:dict 要查的单词 阅读全文
posted @ 2011-11-25 09:19 vizhen 阅读(212) 评论(0) 推荐(0)

2011年10月17日

摘要: public class ImageUtil { //缩放图片 public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float)w/width); float scaleHeight = ((float)h/height); matrix.postScale(scaleHeight... 阅读全文
posted @ 2011-10-17 20:44 vizhen 阅读(500) 评论(0) 推荐(0)

2011年10月15日

摘要: Android的应用程序开发可以搭建在各种IDE上,本篇继续介绍Ubuntu 下面的Android 开发环境的构建,上篇已经介绍完了Java开发环境搭建,现在继续完成最后的任务。 我们需要下载:1.Linux下面的android SDK 2.Linux下面Eclipse Android SDK 环境构建 Step 1:下载Android SDK包 从Android开发者官网下载相应操作系统的SDK包。我下载的是 android-sdk_r12-linux_x86.tgz(在不久的以前这个网站是被墙,现在已经解放了,不过在这里我还是要骂下 GFW以及其主要缔造者方滨兴,MG... 阅读全文
posted @ 2011-10-15 10:57 vizhen 阅读(440) 评论(0) 推荐(1)

2011年9月14日

摘要: 本节介绍这个存储私有数据的 API,它使用 android.content.Context.openFileInput、openFileOutput 和 getCacheDir() 来高速缓存数据,当用户卸载掉应用程序时,这些文件就会被移除。存储数据至内部私有存储器:/** * Writes content to internal storage making the content private to * the application. The method can be easily changed to take the MODE * as argument and let t... 阅读全文
posted @ 2011-09-14 16:25 vizhen 阅读(435) 评论(0) 推荐(0)

2011年8月13日

摘要: 原文链接:http://mobiforge.com/developing/story/preserving-user-preferences-android-applications【纯属锻炼,请各位还是看原文】-----------------------------------通常,你都需要在你... 阅读全文
posted @ 2011-08-13 10:30 vizhen 阅读(327) 评论(0) 推荐(0)

2011年7月8日

摘要: 很多音乐播放器界面上都有一个音量seekbar,那么在android里面是如何实现的呢? 首先分析下要解决的问题:1.获取媒体播放的音量。 2.通过seekbar可以增减音量 3.用户按下音量键增减音量,seekbar保持同步 对于第一个问题:Android系统提供AudioManager类来获得系统audio服务。 对于第二个问题:实现seekBarChangeLIstener里面onProgressChanged方法。 对于第三个问题:用线程来同步更新UI。 设置音量的代码:1 private void setVolum()2 {3 4 maxVolume = mAudioManager. 阅读全文
posted @ 2011-07-08 22:40 vizhen 阅读(1021) 评论(0) 推荐(0)