上一页 1 ··· 4 5 6 7 8
2013年12月17日
摘要: 2013-12-17有时候会发现在xml文件中有使用fragment,但是却不是为了显示View,代码如下: 1 6 7 13 14 20 21 可以看到上面xml文件中有LoadInXmlFragment,那我们来看看当进入和退出Activity时Activity和LoadInXmlFragment的生命周期, log如下: 1 // Enter Activity: 2 D/David-Activity( 7378): onCreate 3 D/David-Fragment( 7378): onAttach 4 D/David-Activity( 73... 阅读全文
posted @ 2013-12-17 11:44 wlrhnh 阅读(1583) 评论(0) 推荐(0) 编辑
摘要: 2013-12-171. 根据联系人图片Uri获得图片文件并将它显示在ImageView上, 代码如下: 1 Uri uri = Uri.parse("content://com.android.contacts/display_photo/1"); 2 AssetFileDescriptor afd; 3 try { 4 afd = getContentResolver().openAssetFileDescriptor(uri, "r"); 5 byte[] buffer = new byte[16 * 1024]; 6 Fi... 阅读全文
posted @ 2013-12-17 11:14 wlrhnh 阅读(3525) 评论(1) 推荐(0) 编辑
2013年12月16日
摘要: 1. select SELECT LastName,FirstName FROM Persons; SELECT * FROM Persons;2. where SELECT * FROM Persons WHERE City='Beijing'; SELECT * FROM Persons WHERE FirstName='Thomas' AND LastName='Carter' SELECT * FROM Persons WHERE (FirstName='Thomas' OR FirstName='William& 阅读全文
posted @ 2013-12-16 18:41 wlrhnh 阅读(1370) 评论(0) 推荐(0) 编辑
摘要: 前面一片文章中用到了ContentProviderOperation,那么我们就来看看ContentProviderOperation到底是怎么工作的。1.ContentProviderOperation实现了Parcelable,构造器是私有的,因此不能直接创建该对象,代码如下: 1 public class ContentProviderOperation implements Parcelable { 2 /** @hide exposed for unit tests */ 3 public final static int TYPE_INSERT = 1; 4 ... 阅读全文
posted @ 2013-12-16 18:38 wlrhnh 阅读(2680) 评论(0) 推荐(0) 编辑
摘要: Android添加联系人有两种方式:1. 直接调用插入语句,先插入一个空Item,得到一个id,然后给这个id对应的插入其他信息,如姓名,号码,邮件等;2. 利用ContentProviderOperation, 在系统应用Phonebook中就是采用这种方式, 代码如下:实现了插入姓名,号码以及头像。 1 private boolean saveUpdatedPhoto(long rawContactId, File photoFile) { 2 final Uri outputUri = Uri.withAppendedPath(ContentUris.with... 阅读全文
posted @ 2013-12-16 18:15 wlrhnh 阅读(2196) 评论(1) 推荐(0) 编辑
2013年12月13日
摘要: 官方的Demo里有DrawerLayout的例子,涉及到ActionBar,这里不用ActionBar,手痒,写个超级简单的小Demo,备着以后或许会用到。详细的内容,可以访问:http://blog.csdn.net/songzhiyong1121/article/details/8949329看代码:DrawerActivity.java 1 public class DrawerActivity extends Activity implements OnClickListener { 2 private DrawerLayout mDrawerLayout = null; 3 ... 阅读全文
posted @ 2013-12-13 11:13 wlrhnh 阅读(2537) 评论(0) 推荐(0) 编辑
2013年12月12日
摘要: 转载自:http://www.linuxidc.com/Linux/2011-11/47587.htm一、利用AndroidAPI函数查看1.1 ActivityManager查看可用内存。1 ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo(); 2 am.getMemoryInfo(outInfo); 3 outInfo.availMem即为可用空闲内存。1.2、android.os.Debug查询PSS,VSS,USS等单个进程使用内存信息MemoryInfo[] memoryInfoArray = a 阅读全文
posted @ 2013-12-12 10:04 wlrhnh 阅读(1659) 评论(0) 推荐(1) 编辑
2013年12月8日
摘要: 如何判断Intent有没有对应的Activity去处理?至少有以下两种方法,最近使用过,随笔记下来,以供查阅。第一种, 如下:1 public boolean isIntentResolvable(Intent intent) {2 return intent.resolveActivity(this.getPackageManager()) != null;3 }第二种,比较复杂,但是能够获得更多信息,有时候更有用:public static boolean isIntentAvailable(String action) { final PackageManager pack... 阅读全文
posted @ 2013-12-08 14:46 wlrhnh 阅读(973) 评论(0) 推荐(0) 编辑
摘要: 受够了百度空间,换个地方,或许会更好。以后有机会会将百度空间你的文章搬过来的。 阅读全文
posted @ 2013-12-08 14:40 wlrhnh 阅读(237) 评论(1) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8