2013年3月4日

android解析xml 三种方式

摘要: XML格式<?xml version="1.0" encoding="utf-8" ?><ROWDATA><ROW> <OBJECTID>72</OBJECTID> <NAME>紫金观</NAME> <LONGITUDE>116.31300336</LONGITUDE> <LATITUDE>39.94504101</LATITUDE></ROW><ROW> <OBJECTID>72< 阅读全文

posted @ 2013-03-04 10:36 _star 阅读(459) 评论(0) 推荐(0)

2013年2月22日

moquette-mqtt 的使用之mqtt Blocking API客户端订阅并接收主题信息

摘要: package com.etrip.mqtt;import java.net.URISyntaxException;import org.fusesource.mqtt.client.BlockingConnection;import org.fusesource.mqtt.client.MQTT;import org.fusesource.mqtt.client.Message;import org.fusesource.mqtt.client.QoS;import org.fusesource.mqtt.client.Topic;import org.slf4j.Logger;import 阅读全文

posted @ 2013-02-22 14:21 _star 阅读(1008) 评论(0) 推荐(0)

moquette-mqtt 的使用之mqtt服务发布主题信息

摘要: 在moquette-mqtt 的mqtt-client中三种方式实现发布消息的方式: 1.采用阻塞式的连接的(BlockingConnection) 2.采用回调式的连接 (CallbackConnection) 3.采用Future样式的连接(FutureConnection)本文采用阻塞式作为实验对象。 MQ 遥测传输 (MQTT) 是轻量级基于代理的发布/订阅的消息传输协议,设计思想是开放、简单、轻量、易于实现。 这些特点使它适用于受限环境。例如,但不仅限于此: 网络代价昂贵,带宽低、不可靠。 在嵌入设备中运行,处理器和内存资源有限。 该协议的特点有: 使用发布/订阅消息模式,提供... 阅读全文

posted @ 2013-02-22 14:20 _star 阅读(2647) 评论(0) 推荐(1)

moquette-mqtt 的使用之mqtt broker的启动

摘要: 在MQTT moquette 中采用MINA作为底层消息的传递方式 本类的目的启动MQTT moquette Broker 的方式,本文的源代码来自 moquette-broker-0.1-jar-with-dependencies.jar 中的server类如果想直接启动 moquette-broker-0.1-jar-with-dependencies.jar的jar文件方式 可以执行一些命令实现 java -jar moquette-broker-0.1-jar-with-dependencies.jar google code 下载MQTT moquette Broker 地址:... 阅读全文

posted @ 2013-02-22 14:18 _star 阅读(2972) 评论(0) 推荐(0)

2013年2月19日

线程池管理

摘要: ThreadPoolExecutor线程池类为java.util.concurrent.ThreadPoolExecutor,常用构造方法为:ThreadPoolExecutor(int corePoolSize, int maximumPoolSize,long keepAliveTime, TimeUnit unit,BlockingQueue<Runnable> workQueue,RejectedExecutionHandler handler)corePoolSize: 线程池维护线程的最少数量maximumPoolSize:线程池维护线程的最大数量keepAliveTi 阅读全文

posted @ 2013-02-19 15:07 _star 阅读(398) 评论(0) 推荐(0)

GBK2ASC

摘要: 1 /** 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/lic... 阅读全文

posted @ 2013-02-19 10:46 _star 阅读(180) 评论(0) 推荐(0)

log日志

摘要: public class Loger { private static boolean CLOSE = !ConfigProperties.LOGER_CLOSE;public static void v(String msg) { if(CLOSE)return; final StackTraceElement[] stack = new Throwable().getStackTrace(); final int i = 1; final StackTraceElement ste = stack[i];Log.v(ste.getClassName(), String.format(&qu 阅读全文

posted @ 2013-02-19 10:34 _star 阅读(212) 评论(0) 推荐(0)

SystemClock.sleep和Thread.sleep的区别

摘要: 在Java中我们处理线程同步问题时,处理延迟可能会使用Thread类的sleep方法,这里抛开concurrent类的一些方法,其实Android平台还提供了一个SystemClock.sleep方法,它们有什么区别呢? 我们每次调用Thread.sleep时可能会出现InterruptedException异常,而SystemClock.sleep方法则不会,在SDK上有这样的描述,它将会忽略中断异常。SystemClock.sleep(millis) is a utility function very similar to Thread.sleep(millis), but it ign 阅读全文

posted @ 2013-02-19 10:16 _star 阅读(480) 评论(0) 推荐(0)

android 捕获异常 CrashHandler

摘要: public class CrashHandler implements UncaughtExceptionHandler { /** 是否开启日志输出,在Debug状态下开启, * 在Release状态下关闭以提示程序性能 * */ public static final boolean DEBUG = true; /** CrashHandler实例 */ private static CrashHandler INSTANCE; /** 程序的Context对象 */ private Context mContext; ProgressDialog progressDial... 阅读全文

posted @ 2013-02-19 10:04 _star 阅读(839) 评论(0) 推荐(0)

2013年2月18日

oncreate 获取控件大小

摘要: //------------------------------------------------方法一 int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); imageView.measure(w, h); int height =imageView.getMeasuredHeight(); ... 阅读全文

posted @ 2013-02-18 11:17 _star 阅读(292) 评论(0) 推荐(0)

导航