摘要: public static Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); ... 阅读全文
posted @ 2012-09-01 19:12 lipeil 阅读(1423) 评论(0) 推荐(0) 编辑
摘要: ExecutorService pool; android 自身的线程池 public void Init() { pool = Executors.newFixedThreadPool(3); for(int j=0 ; j< 10 ; j++) { Thread thread = new Thread() { public void run() { ... 阅读全文
posted @ 2012-09-01 19:04 lipeil 阅读(7549) 评论(2) 推荐(0) 编辑
摘要: 以如下布局为例:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Li 阅读全文
posted @ 2012-09-01 17:43 lipeil 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 第一步:保存apk文件到sdcard或者其他地方第二步:修改apk文件的权限为可执行 ,例如chmod ‘777’ file:String command = "chmod " + permission + " " + path;Runtime runtime = Runtime.getRuntime();runtime.exec(command);第三步:使用Intent 调用安装:Intent intent = new Intent(Intent.ACTION_VIEW);intent.addFlags(Intent.FLAG_ACTIVITY_NE 阅读全文
posted @ 2012-09-01 16:20 lipeil 阅读(13761) 评论(0) 推荐(0) 编辑
摘要: android 中可以设置自己添加的字体:比如宋体之类的Typeface typeface=Typeface.createFromAsset(getAssets(),"font/font_"+i+".ttf"); textView.setTypeface(typeface);汉字字体通常都是10M左右,放到apk中相当不划算 - -!,还是用图片代替。 阅读全文
posted @ 2012-09-01 16:15 lipeil 阅读(351) 评论(0) 推荐(1) 编辑
摘要: dip或dp,(device independent pixels,设备独立像素),一般为了支持WVGA、HVGA和QVGA使用这个,不依赖像素。 这里要特别注意dip与屏幕密度有关,而屏幕密度又与具体的硬件有关,硬件设置不正确,有可能导致dip不能正常显示。在屏幕密度为160的显示屏上,1dip= 阅读全文
posted @ 2012-09-01 16:09 lipeil 阅读(518) 评论(0) 推荐(0) 编辑
摘要: surfaceView和View最本质的区别在于:surfaceView是在一个新起的单独线程中可以重新绘制画面,而View必须在UI的主线程中更新画面。那么在UI的主线程中更新画面 可能会引发问题,比如你更新画面的时间过长,那么你的主UI线程会被你正在画的函数阻塞。那么将无法响应按键,触屏等消息。当使用surfaceView 由于是在新的线程中更新画面所以不会阻塞你的UI主线程。但这也带来了另外一个问题,就是事件同步。比如你触屏了一下,你需要surfaceView中 thread处理,一般就需要有一个event queue的设计来保存touch event,这会稍稍复杂一点,因为涉及到线程同 阅读全文
posted @ 2012-08-31 23:34 lipeil 阅读(28441) 评论(1) 推荐(1) 编辑
摘要: TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);int mGalleryItemBackground = a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0);a.recycle(); ImageView image = (ImageView)findViewById(R.id.imageview);image.setBackgroundResource(mGalleryItemBackground); ... 阅读全文
posted @ 2012-08-31 23:28 lipeil 阅读(921) 评论(0) 推荐(0) 编辑
摘要: android:scrollbarTrackVertical="@drawable/music_bar" //设置滚动条android:scrollbarThumbVertical="@drawable/music_track" //设置滚动子 阅读全文
posted @ 2012-08-30 12:49 lipeil 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 1、在java中调用 Native代码,JNI的写法#include <string.h>#include <jni.h>#include <stdio.h>#include <android/log.h>#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))JNIEXPORT jstring JNICALLJava_com_ndk_NDKFirstActivity_getTime( JNIE 阅读全文
posted @ 2012-08-27 23:51 lipeil 阅读(1317) 评论(0) 推荐(0) 编辑
摘要: 1、Java文件中的所有的文件名、包名、类名、方法名,不要有_(下划线),这样会与 JNI中的 方法名混淆。2、多个c文件中含有 jni方法,则需要添加到LOCAL_SRC_FILES := ndk_first.c math.c3、在jni文件中使用日志需要配置如下:#include <android/log.h>#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "ProjectName", __VA_ARGS__)#define LOGD(...) __android_log_print(AN 阅读全文
posted @ 2012-08-27 23:43 lipeil 阅读(1702) 评论(0) 推荐(0) 编辑
摘要: 1、NDK 一中已经提到,使用eclipse中的配置 ,自动编译2、手动编译(推荐)打开bash.exe(即启动cygwin)使用cd $NDK 进入/cygdrive/e/android-ndk-r5/用cd进入到对应的目录;进入对应的目录,使用 $NDK/ndk-build 编译得到结果,例如1、 我们选择ndk自带的例子hello-jni,我的位于E:\android-ndk-r5\samples\hello-jni(根据你具体的安装位置而定),2、 运行cygwin,输入命令cd /cygdrive/e/android-ndk-r5/samples/hello-jni,进入到E:\an 阅读全文
posted @ 2012-08-27 23:35 lipeil 阅读(7778) 评论(0) 推荐(0) 编辑
摘要: 一:什么是NDK?NDK 提供了一系列的工具,帮助开发者快速开发C(或C++)的动态库,并能自动将so 和java 应用一起打包成apk。这些工具对开发者的帮助是巨大的。NDK 集成了交叉编译器,并提供了相应的mk 文件隔离CPU、平台、ABI 等差异,开发人员只需要简单修改mk 文件(指出“哪些文件需要编译”、“编译特性要求”等),就可以创建出so。NDK 可以自动地将so 和Java 应用一起打包,极大地减轻了开发人员的打包工作。比较简单的说,NDK是一套交叉编译工具,它可以帮你把你用C或C++书写的代码,编译为.so(类似与win下的.dll)格式的文件,使你可以在你的Android程序 阅读全文
posted @ 2012-08-27 23:27 lipeil 阅读(1416) 评论(0) 推荐(0) 编辑
摘要: <ImageView android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/zixun" android:scaleType="matrix" />关键点:缩放的内容不能是图片的背景,一定要是... 阅读全文
posted @ 2012-08-27 23:08 lipeil 阅读(3051) 评论(0) 推荐(1) 编辑
摘要: private String getVersionName() throws Exception { // 获取packagemanager的实例 PackageManager packageManager = getPackageManager(); // getPackageName()是你当前类的包名,0代表是获取版本信息 PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0); ... 阅读全文
posted @ 2012-08-27 23:06 lipeil 阅读(191) 评论(0) 推荐(0) 编辑
摘要: xmlns是什么意思我们经常会在网页中碰到形如<html xmlns=”http://www.w3.org/2001/xhtml”>这样的代码,或在是android 编码中的main.xml中看到形如<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 那后面的xmlns是表示什么意思呢?官方概念:xmlns是xml namespace的缩写,也就是XML命名空间,xmlns 属性可以在文档中定义一个或多个可供选择的命名空间。该属性可以放置在文档内任何元素的开始标签 阅读全文
posted @ 2012-08-27 23:05 lipeil 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 1、AIDL (Android Interface Definition Language)2、AIDL 适用于 进程间通信,并且与Service端多个线程并发的情况,如果只是单个线程 可以使用 Messenger ,如果不需要IPC 可以使用Binder3、AIDL语法:基础数据类型都可以适用,List Map等有限适用。static field 不适用。4、AIDL基本用法第一步:实现.aidl文件接口描述文件1、导入的包名2、如果有使用Object对象,需要该对象 implement Parcelable 接口,并且需要导入该接口包名+类名; 如果是primitive type 不需要这 阅读全文
posted @ 2012-08-27 22:50 lipeil 阅读(19888) 评论(3) 推荐(3) 编辑
摘要: int time = 1345101858;long realTime = time *1000;realTime的值并不是等于1345101858000 而是等于 777094352,应该将 time的类型也改为 long 才正确 阅读全文
posted @ 2012-08-27 14:21 lipeil 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 补充:在Activity 与Service中的循环线程并不会因为Activity 、Service的 销毁而终止。IntentService中同样也是1、启动服务的两种方式: startService 没有返回,用于播放音乐,下载文件 bingService 有返回,并且可以实现进程间交互。多个组件可以同时与一个Service 绑定,当且仅当所有绑定解除 Service is Destory 2、可以同时使用两种方式调用同一Service3、在另外一个app中也可以访问Service, 如果不想让其他app访问可以设置android:exported=“fal... 阅读全文
posted @ 2012-08-27 00:07 lipeil 阅读(1089) 评论(1) 推荐(0) 编辑
摘要: 1、IMEI(International Mobile Equipment Identity) 是国际移动设备身份码的缩写,国际移动装备辨识码,是由15位数字组成的"电子串号",它与每台手机一一对应,而且该码是全世界唯一的。每一只手机在组装完成后都将被赋予一个全球唯一的一组号码,这个号码从生产到交付使用都将被制造生产的厂商所记录。2、IMSI 国际移动用户识别码(IMSI:International Mobile SubscriberIdentification Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使 阅读全文
posted @ 2012-08-25 16:53 lipeil 阅读(421) 评论(0) 推荐(0) 编辑
摘要: 手势层控件,捕获手势轨迹<android.gesture.GestureOverlayViewandroid:id="@+id/gestures_overlay"android:layout_width="match_parent"android:layout_height="0dip"android:layout_weight="1.0"android:gestureStrokeType="multiple" />手势控件,能用来捕获手势轨迹GestureLibrary 用来保存 阅读全文
posted @ 2012-08-25 16:51 lipeil 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 1、从TextView 返回的Editabel 可以是先append功能 Editable text = (Editable)mResults.getText(); text.append("(okay "); TextView 另一强大功能setError(CharSequence error) 可以设置PopUp提示,用来说明输入为空,或者错误 重载方法setError(CharSequence error, Drawable icon);其中icon为文本框内的图标 2、可以将Activity 的属性设置为Theme.Dialog显示任意 view 详情可以查看Cus 阅读全文
posted @ 2012-08-25 16:49 lipeil 阅读(582) 评论(0) 推荐(0) 编辑
摘要: alias 的基本使用方法为:alias 新的命令='原命令 -选项/参数'。例如:alias openpdf='xdg-open'在 ~/.bashrc 文件中添加 上面的修改,然后重启终端生效。 阅读全文
posted @ 2012-08-24 11:56 lipeil 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1、再android上使用混淆比较简单,只需要在project.propreties文件中添加一行proguard.config=proguard.cfg如果不存再proguard.cfg文件,可以自己创建2、如果引入了第三方包,又不需要混淆则:指定第三方的包 -libraryjars-libraryjars libs/android-support-v4.jar忽略jar包中的警告:-dontwarn android.support.v4.**忽略警告:-ignorewarnings指定不混淆的包:-keep class android-support-v4.**{*;}指定继承包的类不混淆 阅读全文
posted @ 2012-08-24 11:24 lipeil 阅读(387) 评论(0) 推荐(0) 编辑
摘要: Wi-Fi 原先是无线保真的缩写,Wi-Fi 的英文全称为wireless fidelity,读音为waifai(拼音读法,均为一声),英文音标/ˈwaɪfaɪ/, wireless [英] [ˈwaɪəlɪs] fidelity[英] [fiˈdeliti]。在无线局域网的范畴是指“无线相容性认证”,实质上是一种商业认证,同时也是一种无线联网的技术,以前通过网线连接电脑,而现在则是通过无线电波来连网;常见的就是一个无线路由器,那么在这个无线路由器的电波覆盖的有效范围都可以采用WIFI连接方式进行联网,如果无线路由器连接了一条ADSL线路或者别的上网线路,则又被称为“热点”。判断网络连接状态: 阅读全文
posted @ 2012-08-22 23:12 lipeil 阅读(1058) 评论(0) 推荐(0) 编辑
摘要: Post与Get区别: (1)GET提交,请求的数据会附在URL之后(就是把数据放置在HTTP协议头中),以?分割URL和传输数据,多个参数用&连接;例如:login.action?name=hyddd&password=idontknow&verify=%E4%BD%A0 %E5%A5%BD。如果数据是英文字母/数字,原样发送,如果是空格,转换为+,如果是中文/其他字符,则直接把字符串用BASE64加密,得出如: %E4%BD%A0%E5%A5%BD,其中%XX中的XX为该符号以16进制表示的ASCII。 POST提交:把提交的数据放置在是HTTP包的包体中。上文示例 阅读全文
posted @ 2012-08-22 23:07 lipeil 阅读(2023) 评论(0) 推荐(0) 编辑
摘要: HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); //文件下载位置 规定的格式 “byte=xxxx-” String start = "bytes="+startPosition + "-"; //设置文件开始的下载位置 使用 Range字段设置断点续传 conn.setReq... 阅读全文
posted @ 2012-08-22 22:47 lipeil 阅读(5870) 评论(0) 推荐(1) 编辑
摘要: Android 背景颜色处理[使用 Drawable.setColorFilter(),或者paint.setColorFilter()]button.getBackground().setColorFilter(new LightingColorFilter(0xEEEEEFF, 0xFFAA0000))这里主要说明一下 LightingColorFilter,它是一个 ColorMatrix对象,ColorMatrix对象用处较大,多用来对图片进行特效处理,如色彩变化、位置及变形处理。ColorMatrix顾名思义颜色矩阵,google定义其为一个5x4的矩阵,但实际上使用一个一维数组表示 阅读全文
posted @ 2012-08-22 22:39 lipeil 阅读(3230) 评论(0) 推荐(0) 编辑
摘要: 内存泄漏指长期的持有不再使用的对象,导致该块内存被占用,无法被其他对象使用。Java中的内存泄漏不同于C/C++中的内存泄漏,它只影响该java程序本身,一旦程序结束,该内存还是会被释放。而C/C++中的内存泄漏则不同,在一个程序中的内存泄漏,技术程序结束,也无法被回收。需要重启系统,重新分配内存,才可以回收。故可以认为java的内存泄漏是程序级的而C/C++的内存泄漏是系统级的1、注册没有取消()2、集合中的对象没清理()3、资源对象没关闭(Cursor file DB等)4、不良代码成内存压力(Bitmap没有recycle ,Adapter 没有使用缓存convertView)5、对上下 阅读全文
posted @ 2012-08-22 22:25 lipeil 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 1、Animation Tween//xml中组合动画<set android:shareInterpolator="false"> <scale android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1.0" android:toXScale="1.4" android:fromYScale="1.0" android:toYScale=" 阅读全文
posted @ 2012-08-22 22:21 lipeil 阅读(719) 评论(0) 推荐(0) 编辑
摘要: LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); view = mLayoutInflater.inflate(resId, null); //初始化PopupWindow mPopupWindow = new PopupWindow(view, 400, LayoutParams.WRAP_CONTENT); // mPopupWindow.setBackgroundDrawable(new... 阅读全文
posted @ 2012-08-22 22:14 lipeil 阅读(1491) 评论(0) 推荐(0) 编辑
摘要: 源码已经下载放到快盘资源。1. 简单介绍Pinyin4j是sourceforge.net上的一个开源项目,功能非常强大:支持同一汉字有多个发音还支持拼音的格式化输出,比如第几声之类的,同时支持简体中文、繁体中文转换为拼音…使用起来也非常简单。下面是其官方网址,其中提供了下载:http://pinyin4j.sourceforge.net/pinyin4j的简单介绍以及 源码下载地址:http://www.open-open.com/home/space-2869-do-blog-id-5493.html 阅读全文
posted @ 2012-08-22 22:02 lipeil 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 1、实现provider接口,提供给其他程序调用第一步: 在manifest.xml中配置 provider 组件其中:name表示 自定义继承于ContentProvider的类名(或者加上包名) authorities表示主机名,类似域名第二步: 创建数据库,表用来保存数据public c... 阅读全文
posted @ 2012-08-22 21:58 lipeil 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 1、JSON(JavaScript Object Notation) 定义:一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性。业内主流技术为其提供了完整的解决方案(有点类似于正则表达式,获得了当今大部分语言的支持),从而可以在不同平台间进行数据交换。JSON采用兼容性很高的文本格式,同时也具备类似于C语言体系的行为。 – Json.org2、JSON的结构:(1) Name/Value Pairs(无序的):类似所熟知的Keyed list、Hash table、Disctionary和Associative array。在Android平台中同时存在另外一个类"Bund 阅读全文
posted @ 2012-08-22 09:03 lipeil 阅读(1303) 评论(0) 推荐(0) 编辑
摘要: 通知:NotificationManager nm = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);// 获取Notificationmanager Notification notification = new Notification(R.drawable.icon ,info.getAsString(Args.Info.TITLE) , System.currentTimeMillis());//初始化Notification notification... 阅读全文
posted @ 2012-08-20 16:48 lipeil 阅读(1289) 评论(0) 推荐(0) 编辑
摘要: HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer)HTTPS和HTTP的区别 一、https协议需要到ca申请证书,一般免费证书很少,需要交费。 二、http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议。 三、http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443。 四、http的连接很简单,是无状态的;HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,比http协议安全。SSL协议位于TCP/IP协议与... 阅读全文
posted @ 2012-08-20 10:33 lipeil 阅读(2315) 评论(0) 推荐(0) 编辑
摘要: android:divider="#FF0000" 定义分隔符为红色android:dividerHeight="6px" 定义分割符的高度Item之间无间隙:在xml文件中ListView控件中加入如下属性:android:divider="#00000000"或者在javaCode中如下定义:listView.setDividerHeight(0);自定义的BaseAdapter中调用notifyDataSetChanged()方法会重新调用BaseAdapter的getView()方法。 点击Item时无背景颜色变化:在xml文 阅读全文
posted @ 2012-08-18 14:43 lipeil 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 使用 loadData方法是中文部分会出现乱码,即使指定“utf-8”、“gbk”、“gb2312”也一样。 webView.getSettings().setDefaultTextEncodingName("UTF -8");//设置默认为utf-8// webView.loadData(data, "text/html", "UTF -8");//API提供的标准用法,无法解决乱码问题 webView.loadData(data, "text/html; charset=UTF-8", null);//这种写法 阅读全文
posted @ 2012-08-18 13:59 lipeil 阅读(15157) 评论(2) 推荐(2) 编辑
摘要: 1、再xml文件中配置如:<string name="hello"><u>phone: 1390123456</u></string>2、再代码中配置如://拨电话SpannableStringBuilder ss = new SpannableStringBuilder(text); ss.setSpan(new URLSpan("tel:"+text), 0, text.length() , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setMovementM 阅读全文
posted @ 2012-08-18 10:49 lipeil 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 1、创建android 项目android create project --target <targetID> --path <projectPath> --activity <activityName> --package <packageName>其中 targetID 通过 命令 android list target 获取2、编译 ant debug # 或者ant release发布模式参考网址:http://rain-2372.iteye.com/blog/713021 阅读全文
posted @ 2012-08-09 11:59 lipeil 阅读(159) 评论(0) 推荐(0) 编辑