2012年5月26日

Android 桌面悬浮框

摘要: 最近看好多程序都弄了一个桌面的悬浮框,用来监视内存,或者是显示歌词什么的,自己手动实现一个,代码如下:@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); //通过WindowManager将浮动的窗口添加到屏幕 mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); mActivityManag... 阅读全文

posted @ 2012-05-26 14:16 达小生 阅读(1453) 评论(2) 推荐(2) 编辑

2012年5月13日

AsyncTask 源码分析

摘要: AsyncTask 异步任务,可以很方便的在应用中执行下载等可能阻塞UI Thread的任务,现在分析一下它的源码。首先列出AsyncTask的一些核心方法和域:public abstract class AsyncTask<Params, Progress, Result> { private static final int CORE_POOL_SIZE = 5; //核心线程数 private static final int MAXIMUM_POOL_SIZE = 128; //最大线程数 private static final int KEEP_ALIVE ... 阅读全文

posted @ 2012-05-13 21:30 达小生 阅读(744) 评论(1) 推荐(0) 编辑

2012年5月9日

Android Bound Services 笔记

摘要: Service绑定到Android Component组件上,其通讯方式一般是如下三种在onBind(Intent intent)中返回Binder对象,通过此接口与Service交互通过IBinder对象创建一个Messenger,通过Handler的方式来与Service交互通过AIDL进行交互第一种返回Binder的方式是最为方便的,因为可以在Binder中直接返回Service实例,使Component直接与Service通信。但是存在一个局限性,就是只有在Service与Component在同一个进程中的时候才可以通过Binder的方式进行,如果这个Service是一个程序内部使用的 阅读全文

posted @ 2012-05-09 19:01 达小生 阅读(310) 评论(0) 推荐(0) 编辑

2012年5月8日

Android Service 笔记

摘要: 学习了一下Service,网上常见的一些就不说了,说一下感觉容易给人造成误解的地方1. 如Service的创建都是在新进程创建的么?其实不是的,在 Dev Guide中写道:Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service 阅读全文

posted @ 2012-05-08 19:55 达小生 阅读(695) 评论(0) 推荐(1) 编辑

2012年5月6日

高效 list adapter

摘要: Android api demo里面有一个编写高效list adapter的demo,里面写了建议的两条高效原则1. 在getView方法中,重复利用 convertView,convertView是旧的View,建议先判断是否为空,如果不为空,可以修改其内容来显示新的row。 public View getView(int position, View convertView, ViewGroup parent) { SpeechView sv; if (convertView == null) { sv... 阅读全文

posted @ 2012-05-06 14:09 达小生 阅读(445) 评论(0) 推荐(1) 编辑

导航