編輯:關於Android編程
1.獲得通話記錄:
private void getCallHistory() {
Call call = null;
Cursor cursor = this.getActivity().getContentResolver()
.query(CallLog.Calls.CONTENT_URI, null, null, null, null);
if (cursor.getCount() <= 0) {
return;
}
cursor.moveToFirst();
do {
call = new Call();
/* Reading Name */
String nameTemp = cursor.getString(cursor
.getColumnIndex(CallLog.Calls.CACHED_NAME));
if (nameTemp == null) {
nameTemp = "";
}
if ("".equals(nameTemp)) {
call.name = "";
} else {
call.name = nameTemp;
}
/* Reading Date */
call.date = cursor.getLong(cursor
.getColumnIndex(CallLog.Calls.DATE));
/* Reading duration */
call.duration = cursor.getLong(cursor
.getColumnIndex(CallLog.Calls.DURATION));
/* Reading Date */
call.type = cursor
.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE));
call.phoneNumber = cursor.getString(cursor
.getColumnIndex(CallLog.Calls.NUMBER));
calls.add(call);
} while (cursor.moveToNext());
}
2. 獲得短信記錄
private void getAllSms() {
ContentResolver cr = this.getActivity().getContentResolver();
Uri uri = Uri.parse("content://sms/");
Message message = null;
messages.clear();
Cursor c = cr.query(uri, null, null, null, null);
int totalSms = c.getCount();
if (totalSms <= 0) {
return;
}
if (c.moveToFirst()) {
for (int i = 0; i < totalSms; i++) {
message = new Message();
if (c.getString(
c.getColumnIndexOrThrow(Telephony.Sms.Inbox.TYPE))
.contains("1")) {
message.type = "inbox";
} else {
message.type = "send";
}
// message.phoneNumber = c.getString(c
// .getColumnIndexOrThrow(Telephony.Sms.Inbox.ADDRESS));
message.phoneNumber = c.getString(c
.getColumnIndexOrThrow("address"));
message.name = getNameByPhoneNumber(cr, message.phoneNumber);
messages.add(message);
c.moveToNext();
}
}
c.close();
}
Android 6.0指紋識別App開發案例
在android 6.0中google終於給android系統加上了指紋識別的支持,這個功能在iPhone上早就已經實現了,並且在很多廠商的定制的ROM中也都自己內部實現
Android性能優化摘錄
性能相關App啟動提高程序的啟動速度意義重大,很顯然,啟動時間越短,用戶才越有耐心等待打開這個APP進行使用,反之啟動時間越長,用戶則越有可能來不及等到APP打開就已經切
浮窗開發之窗口層級
最近在項目中遇到了這樣的需求:需要在特定的其他應用之上懸浮自己的UI交互(拖動、輸入等復雜的UI交互),和九游的浮窗類似,不過我們的比九游的體驗更好,我們越過了很多授權的
深入理解Binder
Binder概述一句話概括進程通信:進程間的數據傳遞。Binder是Anroid系統裡最重要的進程通信方式,很多文章會直接用代碼、原理類的文字進行描述,對於接觸Andro