随笔分类 -  android移动开发

摘要:当屏幕多久没有点击的时候,进行某种操作就是所谓的锁屏功能。onCreate: public void addRunnable() { handler.postDelayed(runnable, Constant.WAIT_TIME); }监听触摸事件: @Overri... 阅读全文
posted @ 2015-03-31 17:11 暗殇 阅读(356) 评论(0) 推荐(0)
摘要:转载自:http://www.trinea.cn/android/java-android%E7%BA%BF%E7%A8%8B%E6%B1%A0/介绍new Thread的弊端及Java四种线程池的使用1、new Thread的弊端执行一个异步任务你还只是如下new Thread吗?new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub }}).start();那你就out太多了,new Thread的弊端如下:a. 每次new Th... 阅读全文
posted @ 2013-11-04 09:52 暗殇 阅读(591) 评论(0) 推荐(0)
摘要:webView = (WebView) findViewById(R.id.info_detail_webview); WebSettings webSettings = webView.getSettings(); webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); webSettings.setJavaScriptEnabled(true); // 添加js交互接口类,并起别名 imagelistner LogUti... 阅读全文
posted @ 2013-10-11 13:45 暗殇 阅读(596) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * MD5加密 * * @version 2013-8-22 */public class MD5Util { // 用来将字节转换成 16 进制表示的字符 static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c 阅读全文
posted @ 2013-08-22 13:28 暗殇 阅读(336) 评论(0) 推荐(0)
摘要:private static final String KEY = "xxxxxx"; // KEY的字节长度必须超过24 public DESUtil(){ super(); } /** DES加密 * @param str 要加密的内容 */ public String getDES(String str){ if(TextUtils.isEmpty(str)){ return null; } try { b... 阅读全文
posted @ 2013-08-22 13:26 暗殇 阅读(871) 评论(0) 推荐(0)
摘要:1.获取versionName,versionCode try { String version = this.getPackageManager().getPackageInfo(getPackageName(),0).versionName; int versionCode = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { /... 阅读全文
posted @ 2013-05-03 13:50 暗殇 阅读(191) 评论(0) 推荐(0)
摘要:开发过程中,友盟API能够有效的帮助到我们对APP的相关数据的统计。要使用到友盟的API,我们首先要在友盟的官方网站注册一个账号,并且新建一个应用。友盟统计API:第一步:在项目的mainfest里进行注册 第二步:在父Activity的onResume/onPause里进行关联: @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); MobclickAgent.onPau... 阅读全文
posted @ 2013-04-22 15:27 暗殇 阅读(1023) 评论(0) 推荐(0)
摘要:/** * An object to convert Chinese character to its corresponding pinyin string. * For characters with multiple possible pinyin string, only one is selected * according to collator. Polyphone is not supported in this implementation. * This class is implemented to achieve the best runtime performance 阅读全文
posted @ 2013-03-09 17:37 暗殇 阅读(625) 评论(2) 推荐(0)
摘要:项目中我们经常会碰到这种情况,开启一个后台Service进行网络请求。当满足我们的条件发送一个广播,通过广播来改变UI。首先:我们应该注册Service和广播:mainfest.xml: <!--Service服务--> <service android:enabled="true" android:name=".service.MyService"> <intent-filter> <action android:name="org.allin.android.musicService" / 阅读全文
posted @ 2013-03-09 17:25 暗殇 阅读(397) 评论(0) 推荐(0)
摘要:1.调用系统发短信界面: Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("smsto:xxxxxxxxx"));//设置收件人号码 intent.putExtra("sms_body", "reset");//设置短信内容 startActivity(intent);2.调用系统的分享功能: String content ... 阅读全文
posted @ 2013-02-01 12:20 暗殇 阅读(171) 评论(0) 推荐(0)
摘要:public class ContactPhotoLoader implements Callback { private static final String LOADER_THREAD_NAME = "ContactPhotoLoader"; /** * Type of message sent by the UI thread to itself to indicate that some photos * need to be loaded. */ private static final int MESSAGE_REQUEST_LOADIN... 阅读全文
posted @ 2013-01-30 16:30 暗殇 阅读(1229) 评论(0) 推荐(0)
摘要:短信信息都储存在系统的数据库中,如果我们想获取相关信息需要根据URI进行查找操作.定义一个实体接收类SmsInfo.java:public class SmsInfo { private String smsbody;//短信内容 private String phoneNumber;//发送短信的电话号码 private String date;//发送短信的日期和时间 private String name;//发送者的名字 private String type;//短信类型 1 接收到的 2 已发出的 public SmsInfo... 阅读全文
posted @ 2013-01-26 10:36 暗殇 阅读(454) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * LruCache缓存Bitmap * (基于内存的缓存,读取时间比较快) */public class LruCacheUtil { private static final String TAG = LruCacheUtil.class.getSimpleName(); private int memClass; private LruCache<String,Bitmap> mMemoryCache;//高速缓存(系统) public static final String BITMAP = "bitma.. 阅读全文
posted @ 2012-12-04 10:51 暗殇 阅读(252) 评论(0) 推荐(0)
摘要:public class FileUtil { /** * 删除某个目录 * * @param srcDir 目录地址 * @throws IOException */ public static void deleteDir(String srcDir) throws IOException{ File file = new File(srcDir); if (!file.exists()) return; File files[] = file.listFiles(); ... 阅读全文
posted @ 2012-12-04 10:33 暗殇 阅读(437) 评论(0) 推荐(0)
摘要:CrashHandler.java:public class CrashHandler implements UncaughtExceptionHandler { public static final String TAG = "CrashHandler"; //系统默认的UncaughtException处理类 private Thread.UncaughtExceptionHandler mDefaultHandler; //CrashHandler实例 private static CrashHandler INSTANCE = new ... 阅读全文
posted @ 2012-12-03 17:28 暗殇 阅读(394) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * Bitmap工具类 */public class BitmapUtil { /** * 以最省内存的方式读取本地资源的图片 或者SDCard中的图片 * * @param imagePath 图片在SDCard中的路径 * @return */ public static Bitmap getSDCardImg(String imagePath){ BitmapFactory.Options opt = new BitmapFactory.Options(); ... 阅读全文
posted @ 2012-11-30 17:56 暗殇 阅读(524) 评论(0) 推荐(0)
摘要:Hello.java:public class Hello{ @DatabaseField(generatedId = true,unique=true) int id; @DatabaseField String word; //这是必须加的,否则会出错 public Hello(){} public int getId() { return id; } public Hello(String word) { super(); this.word = word; } pub... 阅读全文
posted @ 2012-11-12 11:08 暗殇 阅读(290) 评论(0) 推荐(0)
摘要:AsyncDataLoader.java:/** * 异步加载后台数据 * @author gongchaobin * * @version 2011-12-19 */public class AsyncDataLoader extends AsyncTask<Object, Void, Object> { private Dialog loadingDialog; private Context mContext; private List<Object> paramsList = null; private String urlFlag; private i... 阅读全文
posted @ 2012-11-07 15:05 暗殇 阅读(366) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * 日志管理 * [统一管理日志,包括各种级别的日志] */public class Log { /** * 控制日志开关 */ private static boolean LogSwitch = true; /** * 打印verbose级别的日志 * * @param tag 标记 * @param text 日志内容 */ public static void verbose(String tag, String text) ... 阅读全文
posted @ 2012-11-07 10:30 暗殇 阅读(460) 评论(0) 推荐(0)
摘要:异步下载类: class DownloadTask extends Thread{ private int blockSize, downloadSizeMore; private int threadNum = 5; String urlStr, threadNo, fileName; /** * @param urlStr 下载的URL * @param threadNum 下载的线程数 * @param fileName 文件名 */ public... 阅读全文
posted @ 2012-11-05 14:26 暗殇 阅读(322) 评论(0) 推荐(0)