andy_叶的博客
andy_叶 · 共 22 篇文章
编写Android app更新模块遇到的问题分析与总结
前不久接到个任务,在我们的app里面添加更新模块,在之前的版本中,我们的更新都是直接通过浏览器下载apk包来安装更新的,我想各位很大一部分应用的更新方法都是这样,因为它简单、方便,但是他也有许多不好的地方,比如需要用户跳转到浏览器页面、下载不可控、网络不好的情况的下失败无法续传,退出浏览器就无法接着下了等。。 于是我们这个更新模块的需求就来了 1.下载后台进行,退出我们应用下载任务依旧能继续执行操作 2.下载文件支持断点续传 3.下载任务支持没有安装sdcard时也可下载更新 4.notify栏提示操作 对几个需求稍作分析,解决方法如下: 1.下载更新的线程放到一个service中去,ser…
2012-08-21 14:41 · android · 评论(0) · Android
android 数据持久化总结
1、 通过Context.getSharedPreferences(String fileName,int mode)方法,可以打开一个xml文件,文件的位置在/data/data/package_name/shared_prefs/fileName.xml,如果不存在,则会自动创建。可以对该文件进行读写操作,在应用内的各组件之间共享数据。如果将mode设置为Context.MODE_WORLD_READ或者Context.MODE_WORLD_WRITE,则还可以被其他应用访问到。不过这不是android推荐的方式,要实现跨应用共享数据,推荐的方式是用ContentProvider实现 2…
2012-06-01 14:44 · 评论(0) · Android
shape 用法(button)
在实现背景渐变的帖子里 http://androidturing.iteye.com/blog/1238909 有朋友建议看看shape的用法,确实很有帮助。这里我偷懒转一篇比较详细的帖子,和大家一起进步~! Android 中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了解,稍作总结: 先看下面的代码: 复制到剪贴板 XML/HTML代码 <shape> <!-- 实心 --> <solid android:color="#ff9d77"/> <!-- 渐变 --> <gradient android:startColor="#ff8c0…
2012-05-31 17:15 · 评论(0) · Android
Android Launcher抽屉类(SlidingDrawer)的使用
Main.xml代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#808080"> <SlidingDrawer android:id="@+id/sliding_draw…
2012-05-31 16:47 · 评论(0) · Android
android之OnScrollListener 下拉刷新
1.首先创建一个头部xml文件 Xml代码 <?xml version="1.0" encoding="utf-8"?> <!-- ListView的头部 --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <!-- 内容 --> <RelativeLayout android:layout_width="fill_parent" android…
2012-05-31 15:47 · 评论(0)
Android实现ListView异步加载图
ListView异步加载图片是非常实用的方法,凡是是要通过网络获取图片资源一般使用这种方法比较好,用户体验好,下面就说实现方法,先贴上主方法的代码: Java代码 package cn.wangmeng.test; import java.io.IOException; import java.io.InputStream; import java.lang.ref.SoftReference; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import androi…
2012-05-31 15:26 · 评论(0) · 源码