編輯:關於android開發
package com.example.yanlei.wifi;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ListView lvContacts=null;
private Cursor cursor=null;
private Button btnRead=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = new TextView(this);
String str = "";
// 得到contentresolver對象
ContentResolver cr = getContentResolver();
// 取得電話本中開始一項的光標,必須先moveToNext()
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
while (cursor.moveToNext())
{
//取得聯系人的名字索引
int nameIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String contact = cursor.getString(nameIndex);
str += (contact + ":" + "\n");
//取得聯系人的ID索引值
String contactId = cursor.getString(cursor
.getColumnIndex(ContactsContract.Contacts._ID));
Cursor phone = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "="
+ contactId, null, null);
//一個人可能有幾個號碼
while (phone.moveToNext())
{
String strPhoneNumber = phone
.getString(phone
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
str += (strPhoneNumber + "\n");
Log.i("TAG","phoneNumber:"+strPhoneNumber+"contact"+contact);
}
phone.close();
}
cursor.close();
tv.setText(str);
setContentView(tv);
}
}
Android之自定義控件-城市選擇,android控件實現效果: 圖片素材:
基於MVVM的知乎日報應用安卓源碼,mvvm日報安卓源碼使用data binding , dagger2 , retrofit2和rxjava實現的,基於MVVM的知乎日
Android之genymotion模擬器安裝於配置,androidgenymotion 今天是雙休日,可憐沒人陪,只好一個人玩電腦了,之前別人一直給我推薦genymo
Android音頻開發(5):音頻數據的編解碼 前面四篇文章分別介紹了音頻開發必備的基礎知識、如何采集一幀音頻、如何播放一幀音頻、如何存儲和解析wav格式的文件,建議有興