随笔分类 -  移动开发

闹钟管理器AlarmManager基本用法
摘要:闹钟管理器可以在指定的时间触发事件,这样就可以做一些周期性的任务,比如定时更新数据,实现闹铃等。The steps we follow for this exercise are 1. Get access to the alarm manager. 2. Come up with a time to set the alarm. 3. Create a receiver to be invoked. 4. Create a pending intent that can be passed to the alarm manager to invoke the receiver... 阅读全文
posted @ 2012-04-29 10:35 lepfinder 阅读(769) 评论(0) 推荐(0)
在BroadcastReceiver中使用通知
摘要:BroadcastReceiver通常需要向用户传达发生的某件事或状态,可以使用通知栏通知提醒用户。创建通知的过程:1、创建一个合适的通知2、获得通知管理器的权限3、向通知管理器发送通知创建通知时,需要包含以下几个部分:1、要显示的图标2、显示的提示文本3、传送它的时间然后使用Context获取一个名为Context.NOTIFICATION_SERVICE的系统服务来获取到通知管理器,如下所示://Get the notification manager String ns = Context.NOTIFICATION_SERVICE; NotificationManager nm = (N 阅读全文
posted @ 2012-04-28 15:17 lepfinder 阅读(678) 评论(0) 推荐(0)
Android BroadcastReceiver的基本用法
摘要:如下图所示,点击menu右面的broadcast会发送一条广播,广播接受者接受信息后,打印一些调试信息。下面看代码:布局文件layout/main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_ 阅读全文
posted @ 2012-04-28 14:54 lepfinder 阅读(672) 评论(0) 推荐(0)
Android Service基础用法
摘要:演示本地服务的使用方法。布局文件,包含两个按钮,一个启动服务,一个终止服务。<?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=&quo 阅读全文
posted @ 2012-04-28 10:08 lepfinder 阅读(458) 评论(0) 推荐(0)
Android AsyncTask 基本使用
摘要:我们知道Android的activity如果没有在5秒内处理完某个事件,将会触发一个ANR事件,该事件将会极大地影响用户体验。使用Android 的AsyncTask可以以后台线程的形式更新用户界面,可在程序中用来处理一些耗时的操作。比如实现一个从网络上抓取图片显示在一个ImageView中,效果如下图:布局文件main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res 阅读全文
posted @ 2012-04-27 17:04 lepfinder 阅读(485) 评论(0) 推荐(0)