1 /**
2 * 用户行为记录
3 *
4 * @author derson2388
5 *
6 */
7 public class UserActionManager {
8
9 private static UserActionManager manager;
10
11 /**
12 * 工作线程消息队列处理
13 */
14 private Handler mHandler;
15 /**
16 * 日志缓存
17 */
18 private ArrayList<String> mCache = new ArrayList<String>();
19
20 /**
21 * 单例访问,同步上锁
22 *
23 * @return
24 */
25 public synchronized UserActionManager getInstance() {
26 if (null == manager) {
27 manager = new UserActionManager();
28 }
29 return manager;
30 }
31
32 private UserActionManager() {
33 new Thread(new Runnable() {
34
35 @Override
36 public void run() {
37 // 新启动一个工作线程,启动Looper后创建handler处理写入请求
38 Looper.prepare();
39 mHandler = new Handler(Looper.myLooper());
40 Looper.loop();
41 }
42 }).start();
43 }
44 }