资源简介
如果你是安卓开发的新手,你需要了解记事本是如何生成的,那你不妨看看这个代码,详细
代码片段和文件信息
/*
* Copyright (c) 2010-2011 The MiCode Open Source Community (www.micode.net)
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.micode.notes.data;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Data;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
import java.util.HashMap;
public class Contact {
private static HashMap sContactCache;
private static final String TAG = “Contact“;
private static final String CALLER_ID_SELECTION = “PHONE_NUMBERS_EQUAL(“ + Phone.NUMBER
+ “?) AND “ + Data.MIMETYPE + “=‘“ + Phone.CONTENT_ITEM_TYPE + “‘“
+ “ AND “ + Data.RAW_CONTACT_ID + “ IN “
+ “(SELECT raw_contact_id “
+ “ FROM phone_lookup“
+ “ WHERE min_match = ‘+‘)“;
public static String getContact(Context context String phoneNumber) {
if(sContactCache == null) {
sContactCache = new HashMap();
}
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
}
String selection = CALLER_ID_SELECTION.replace(“+“
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI
new String [] { Phone.DISPLAY_NAME }
selection
new String[] { phoneNumber }
null);
if (cursor != null && cursor.moveToFirst()) {
try {
String name = cursor.getString(0);
sContactCache.put(phoneNumber name);
return name;
} catch (IndexOutOfBoundsException e) {
Log.e(TAG “ Cursor get string error “ + e.toString());
return null;
} finally {
cursor.close();
}
} else {
Log.d(TAG “No contact matched with number:“ + phoneNumber);
return null;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-01-09 23:25 MiCode-Notes-6cbf71d\
文件 122 2012-01-09 23:25 MiCode-Notes-6cbf71d\.gitignore
文件 6090 2012-01-09 23:25 MiCode-Notes-6cbf71d\AndroidManifest.xm
文件 10713 2012-01-09 23:25 MiCode-Notes-6cbf71d\NOTICE
文件 1060 2012-01-09 23:25 MiCode-Notes-6cbf71d\README
目录 0 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\
目录 0 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\color\
文件 947 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\color\primary_text_dark.xm
文件 814 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\color\secondary_text_dark.xm
目录 0 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\
文件 3588 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\bg_btn_set_color.png
文件 245 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\bg_color_btn_mask.png
文件 3533 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\call_record.png
文件 3958 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\clock.png
文件 3490 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\delete.png
文件 443 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\dropdown_icon.9.png
文件 3524 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_blue.9.png
文件 3565 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_green.9.png
文件 3458 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_red.9.png
文件 5100 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_ti
文件 5627 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_ti
文件 5061 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_ti
文件 3866 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_ti
文件 6000 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_ti
文件 3441 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_white.9.png
文件 3634 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\edit_yellow.9.png
文件 3161 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\font_large.png
文件 3097 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\font_normal.png
文件 4101 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\font_size_selector_bg.9.png
文件 3099 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\font_small.png
文件 3188 2012-01-09 23:25 MiCode-Notes-6cbf71d\res\drawable-hdpi\font_super.png
............此处省略142个文件信息
相关资源
- 员工管理系统完整版 源代码
- 黄金矿工cocos2d源代码+素材
- 黑白棋源代码
- 《软件测试技术大全》光盘
- FPGA数字存储扫频仪-源代码及PCB图
- workflow实现的源代码
- 人脸表情识别源代码
- 热血江湖V2.0源代码
- 数字时钟设计内含原理图、源代码、
- 基于单片机的火灾报警系统的设计与
- zigbee协议在ns2下的仿真源代码
- 黑鹰远控之H2O完整源代码
- 软件工程作业项目银行账户系统完整
- nvp6134 datasheet and driver
- netbeans 导入源代码
- 异步fifo设计verilog源代码
- 豆瓣网安卓源代码
- minix3源代码
- 实验9X stm32F407zgt6_PWM控制SG90输出实验
- AES算法实现源代码
- 音乐播放器含源代码
- Cocos Creator重力小游戏《给我滚》开源
- DirectX地月系+高度图地形源代码
- LabVIEW 2012 Simon 小游戏 编程 源代码
- 串口精灵源代码 串口精灵源代码
- SIFT\\PCA-SIFT\\SURF论文源代码
- [单片微机原理与接口技术——基于
- 线程池实现蚁群算法的简单并行
- 跨域请求解决方案源代码JSONPCORS
- jfreechartDEMO官网demo与源代码
评论
共有 条评论