android如何获取联络人所有资讯

android如何获取联络人所有资讯,第1张

android如何获取联络人所有资讯 获取联络人必须新增许可权

<uses-permission android:name="androidpermissionREAD_CONTACTS" />

如何获取手机联络人资讯

根据ContactsContractContactsCONTENT_URI查询ContentResolver里面的资料,逐个取值即可。

如何获取sim卡的联络人资讯

根据目前查询的资讯来看,sim联络人的uri有两种:

content:i/adn

content:sim/adn

挨个去取即可。

如何获取联络人所有栏位

package ihopemozyhomeutil;import javautilArrayList;import javautilList;import jsonJSONException;import jsonJSONObject;import androidcontentContext;import androiddatabaseCursor;import androidproviderContactsContractCommonDataKindsEmail;import androidproviderContactsContractCommonDataKindsEvent;import androidproviderContactsContractCommonDataKindsIm;import androidproviderContactsContractCommonDataKindsNickname;import androidproviderContactsContractCommonDataKindsNote;import androidproviderContactsContractCommonDataKindsOrganization;import androidproviderContactsContractCommonDataKindsPhone;import androidproviderContactsContractCommonDataKindsStructuredName;import androidproviderContactsContractCommonDataKindsStructuredPostal;import androidproviderContactsContractCommonDataKindsWebsite;import androidproviderContactsContractData;import androidutilLog;import ihopemozyhomedomainContacts;public class GetContactsInfo {private List<Contacts> list;private Context context;private JSONObject contactData;private JSONObject jsonObject;public GetContactsInfo(Context context) { thiscontext = context;}public String getContactInfo() throws JSONException { 获得通讯录资讯 ,URI是ContactsContractContactsCONTENT_URI list = new ArrayList<Contacts>(); contactData = new JSONObject(); String mimetype = ""; int oldrid = -1; int contactId = -1; Cursor cursor = contextgetContentResolver()query(DataCONTENT_URI,null, null, null, DataRAW_CONTACT_ID); int numm=0; while (cursormoveToNext()) { contactId = cursorgetInt(cursorgetColumnIndex(DataRAW_CONTACT_ID)); if (oldrid != contactId) { jsonObject = new JSONObject(); contactDataput("contact" + numm, jsonObject); numm++; oldrid = contactId; } 取得mimetype型别 mimetype = cursorgetString(cursorgetColumnIndex(DataMIMETYPE)); 获得通讯录中每个联络人的ID 获得通讯录中联络人的名字 if (StructuredNameCONTENT_ITEM_TYPEequals(mimetype)) { String display_name = cursorgetString(cursorgetColumnIndex(StructuredNameDISPLAY_NAME)); String prefix = cursorgetString(cursorgetColumnIndex(StructuredNamePREFIX)); jsonObjectput("prefix", prefix); String firstName = cursorgetString(cursorgetColumnIndex(StructuredNameFAMILY_NAME)); jsonObjectput("firstName", firstName); String middleName = cursorgetString(cursorgetColumnIndex(StructuredNameMIDDLE_NAME)); jsonObjectput("middleName", middleName); String lastname = cursorgetString(cursorgetColumnIndex(StructuredNameGIVEN_NAME)); jsonObjectput("lastname", lastname); String suffix = cursorgetString(cursorgetColumnIndex(StructuredNameSUFFIX)); jsonObjectput("suffix", suffix); String phoicFirstName = cursorgetString(cursorgetColumnIndex(StructuredNamePHONETIC_FAMILY_NAME)); jsonObjectput("phoicFirstName", phoicFirstName); String phoicMiddleName = cursorgetString(cursorgetColumnIndex(StructuredNamePHONETIC_MIDDLE_NAME)); jsonObjectput("phoicMiddleName", phoicMiddleName); String phoicLastName = cursorgetString(cursorgetColumnIndex(StructuredNamePHONETIC_GIVEN_NAME)); jsonObjectput("phoicLastName", phoicLastName); } 获取电话资讯 if (PhoneCONTENT_ITEM_TYPEequals(mimetype)) { 取出电话型别 int phoneType = cursorgetInt(cursorgetColumnIndex(PhoneTYPE)); 手机 if (phoneType == PhoneTYPE_MOBILE) { String mobile = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("mobile", mobile); } 住宅电话 if (phoneType == PhoneTYPE_HOME) { String homeNum = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("homeNum", homeNum); } 单位电话 if (phoneType == PhoneTYPE_WORK) { String jobNum = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("jobNum", jobNum); } 单位传真 if (phoneType == PhoneTYPE_FAX_WORK) { String workFax = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("workFax", workFax); } 住宅传真 if (phoneType == PhoneTYPE_FAX_HOME) { String homeFax = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("homeFax", homeFax); } 寻呼机 if (phoneType == PhoneTYPE_PAGER) { String pager = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("pager", pager); } 回拨号码 if (phoneType == PhoneTYPE_CALLBACK) { String quickNum = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("quickNum", quickNum); } 公司总机 if (phoneType == PhoneTYPE_COMPANY_MAIN) { String jobTel = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("jobTel", jobTel); } 车载电话 if (phoneType == PhoneTYPE_CAR) { String carNum = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("carNum", carNum); } ISDN if (phoneType == PhoneTYPE_ISDN) { String isdn = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("isdn", isdn); } 总机 if (phoneType == PhoneTYPE_MAIN) { String tel = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("tel", tel); } 无线装置 if (phoneType == PhoneTYPE_RADIO) { String wirelessDev = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("wirelessDev", wirelessDev); } 电报 if (phoneType == PhoneTYPE_TELEX) { String telegram = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("telegram", telegram); } TTY_TDD if (phoneType == PhoneTYPE_TTY_TDD) { String tty_tdd = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("tty_tdd", tty_tdd); } 单位手机 if (phoneType == PhoneTYPE_WORK_MOBILE) { String jobMobile = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("jobMobile", jobMobile); } 单位寻呼机 if (phoneType == PhoneTYPE_WORK_PAGER) { String jobPager = cursorgetString(cursorgetColumnIndex(PhoneNUMBER)); jsonObjectput("jobPager", jobPager); } 其他通讯地址 if (postalType == StructuredPostalTYPE_OTHER) { String otherStreet = cursorgetString(cursorgetColumnIndex(StructuredPostalSTREET)); jsonObjectput("otherStreet", otherStreet); String otherCity = cursorgetString(cursorgetColumnIndex(StructuredPostalCITY)); jsonObjectput("otherCity", otherCity); String otherBox = cursorgetString(cursorgetColumnIndex(StructuredPostalPOBOX)); jsonObjectput("otherBox", otherBox); String otherArea = cursorgetString(cursorgetColumnIndex(StructuredPostalNEIGHBORHOOD)); jsonObjectput("otherArea", otherArea); String otherState = cursorgetString(cursorgetColumnIndex(StructuredPostalREGION)); jsonObjectput("otherState", otherState); String otherZip = cursorgetString(cursorgetColumnIndex(StructuredPostalPOSTCODE)); jsonObjectput("otherZip", otherZip); String otherCountry = cursorgetString(cursorgetColumnIndex(StructuredPostalCOUNTRY)); jsonObjectput("otherCountry", otherCountry); } } } cursorclose(); Logi("contactData", contactDatatoString()); return contactDatatoString();}}

拍拍贷如何获取联络人

拍拍贷app 可以获取你的通讯录,新浪有借也一样

而且更加好用

它的话是利息按日计,随时还款。

而一般的网贷如借10000,按照目前不低的年化收益率10%来计算的话, 一个月利息是83左右。 计算公式你记一下 10000x10%=1000(这里得出的是一年的收益) 1000/12=83 (除以12个月,才得到你一个月的)

微锁屏获取联络人资讯有风险吗

国内的很多软体都申请了很多不需要的许可权,锁屏软体应该是不需要读取联络人资讯的,可以安装一些软体取消锁屏软体的读取联络人许可权。

android怎么获取联络人头像

必须先编辑成正方形,或你的联络人有自动减取功能,不然头像肯定变形!

手机常显示易信正在尝试获取联络人资讯

这应该是易信在读取你的联络人,以便获取已经用手机号码注册了易信的手机上的联络人,可以考虑解除安装易信(如果不经常用的话)其实很多软体都喜欢读取个人资讯。。

为什么百度HI新增联络人时总是正在获取联络人资讯

应该是网速慢,如果你确定你的网速正常,那有可能是百度系统出错了。

我也遇到过这种情况。

还有一种可能,就是你新增的联络人不存在,或名字输入错误。

什么软体可以汇出联络人所有资讯

360手机卫士、qq都提供了云端备份通讯录的功能。现在备份到云端伺服器上是最安全的,永远不会丢失,换手机前备份一下,新手机上就可以下载到。平日经常备份联络人资讯,安全可靠有保障。

android开发怎样获取通讯录联络人资讯

public class ContactsActivity extends ListActivity {

Context mContext = null;

/获取库Phon表字段/

private static final String[] PHONES_PROJECTION = new String[] {

PhoneDISPLAY_NAME, PhoneNUMBER, PhotoPHOTO_ID,PhoneCONTACT_ID };

/联络人显示名称/

private static final int PHONES_DISPLAY_NAME_INDEX = 0;

/电话号码/

private static final int PHONES_NUMBER_INDEX = 1;

/头像ID/

private static final int PHONES_PHOTO_ID_INDEX = 2;

/联络人的ID/

private static final int PHONES_CONTACT_ID_INDEX = 3;

/联络人名称/

private ArrayList<String> mContactsName = new ArrayList<String>();

/联络人头像/

private ArrayList<String> mContactsNumber = new ArrayList<String>();

/联络人头像/

private ArrayList<Bitmap> mContactsPhonto = new ArrayList<Bitmap>();

ListView mListView = null;

MyListAdapter myAdapter = null;

@Override

public void onCreate(Bundle savedInstanceState) {

mContext = this;

mListView = thisgetListView();

/得到手机通讯录联络人资讯/

getPhoneContacts();

myAdapter = new MyListAdapter(this);

setListAdapter(myAdapter);

mListViewsetOnItemClickListener(new OnItemClickListener() {

@Override

public void onItemClick(AdapterView<> adapterView, View view,

int position, long id) {

呼叫系统方法拨打电话

Intent dialIntent = new Intent(IntentACTION_CALL, Uri

parse("tel:" + mContactsNumberget(position)));

startActivity(dialIntent);

}

});

superonCreate(savedInstanceState);

}

/得到手机通讯录联络人资讯/

private void getPhoneContacts() {

ContentResolver resolver = mContextgetContentResolver();

获取手机联络人

Cursor phoneCursor = resolverquery(PhoneCONTENT_URI,PHONES_PROJECTION, null, null, null);

if (phoneCursor != null) {

while (phoneCursormoveToNext()) {

得到手机号码

String phoneNumber = phoneCursorgetString(PHONES_NUMBER_INDEX);

当手机号码为空的或者为空栏位 跳过当前回圈

if (TextUtilsisEmpty(phoneNumber))

continue;

得到联络人名称

String contactName = phoneCursorgetString(PHONES_DISPLAY_NAME_INDEX);

得到联络人ID

Long contactid = phoneCursorgetLong(PHONES_CONTACT_ID_INDEX);

得到联络人头像ID

Long photoid = phoneCursorgetLong(PHONES_PHOTO_ID_INDEX);

得到联络人头像Bitamp

Bitmap contactPhoto = null;

photoid 大于0 表示联络人有头像 如果没有给此人设定头像则给他一个预设的

if(photoid > 0 ) {

Uri uri =ContentUriswithAppendedId(ContactsContractContactsCONTENT_URI,contactid);

InputStream input = ContactsContractContactsopenContactPhotoInputStream(resolver, uri);

contactPhoto = BitmapFactorydecodeStream(input);

}else {

contactPhoto = BitmapFactorydecodeResource(getResources(), Rdrawablecontact_photo);

}

mContactsNameadd(contactName);

mContactsNumberadd(phoneNumber);

mContactsPhontoadd(contactPhoto);

}

phoneCursorclose();

}

}

/得到手机SIM卡联络人人资讯/

private void getSIMContacts() {

ContentResolver resolver = mContextgetContentResolver();

获取Sims卡联络人

Uri uri = Uriparse("content:i/adn");

Cursor phoneCursor = resolverquery(uri, PHONES_PROJECTION, null, null,

null);

if (phoneCursor != null) {

while (phoneCursormoveToNext()) {

得到手机号码

String phoneNumber = phoneCursorgetString(PHONES_NUMBER_INDEX);

当手机号码为空的或者为空栏位 跳过当前回圈

if (TextUtilsisEmpty(phoneNumber))

continue;

得到联络人名称

String contactName = phoneCursor

getString(PHONES_DISPLAY_NAME_INDEX);

Sim卡中没有联络人头像

mContactsNameadd(contactName);

mContactsNumberadd(phoneNumber);

}

phoneCursorclose();

}

}

class MyListAdapter extends BaseAdapter {

public MyListAdapter(Context context) {

mContext = context;

}

public int getCount() {

设定绘制数量

return mContactsNamesize();

}

@Override

public boolean areAllItemsEnabled() {

return false;

}

public Object getItem(int position) {

return position;

}

public long getItemId(int position) {

return position;

}

public View getView(int position, View convertView, ViewGroup parent) {

ImageView iamge = null;

TextView title = null;

TextView text = null;

if (convertView == null) {

convertView = LayoutInflaterfrom(mContext)inflate(

Rlayoutcolorlist, null);

iamge = (ImageView) convertViewfindViewById(Ridcolor_image);

title = (TextView) convertViewfindViewById(Ridcolor_title);

text = (TextView) convertViewfindViewById(Ridcolor_text);

}

绘制联络人名称

titlesetText(mContactsNameget(position));

绘制联络人号码

textsetText(mContactsNumberget(position));

绘制联络人头像

iamgesetImageBitmap(mContactsPhontoget(position));

return convertView;

}

}

}

第一步:找到需要访问该内核节点的进程(process),笔者自己这个节点由system_server进程来访问

第二步:打开文件AndroidL/android/external/sepolicy/file_contextsbe

仿照这个文件里的写法,为这个定义一个自己想要的名字:

/dev/tegra u:object_r:video_device:s0

/dev/tf_driver u:object_r:tee_device:s0

/dev/tty u:object_r:owntty_device:s0

/dev/tty[0-9] u:object_r:tty_device:s0

/dev/ttyS[0-9] u:object_r:serial_device:s0

/dev/wf_bt u:object_r: wf_bt_device:s0

wf_bt_device是自定义,其他左右两边的内容都和上面的范例一致。

第三步:打开文件AndroidL/android/external/sepolicy/devicete

仿照这个文件里的写法,将刚刚第二步写的wf_bt_device声明为dev_type:

# Device types

type device, dev_type, fs_type;

type alarm_device, dev_type, mlstrustedobject;

type adb_device, dev_type;

type ashmem_device, dev_type, mlstrustedobject;

type audio_device, dev_type;

type binder_device, dev_type, mlstrustedobject;

type block_device, dev_type;

type camera_device, dev_type;

type wf_bt_device, dev_type;

第四步:

AndroidL/android/external/sepolicy/目录下很多te文件都是以进程名来结尾的,比如有针对surfaceflinger进程的surfaceflinger,有针对vold进程的voldte,

刚刚从第一步得到,这个节点是由system_server进程来访问,所以,找到system_serverte打开,加入允许这个进程对/dev/wf_bt的读写权限,

# Read/Write to /proc/net/xt_qtaguid/ctrl and and /dev/xt_qtaguid

allow system_server qtaguid_proc:file rw_file_perms;

allow system_server qtaguid_device:chr_file rw_file_perms;

# chr_file表示字符设备文件,如果是普通文件用file,目录请用dir

# rw_file_perms代表读写权限

allow system_server wf_bt_device:chr_file rw_file_perms;

这句话的意思是:允许system_server进程拥有对wf_bt_device的这个字符设备的读写权限。

改了这些之后,就可以make installclean;make -j16编译image来验证权限是否获取成功。

fd =open("/dev/wf_bt",O_RDONLY | O_NOCTTY);

以上就是关于android如何获取联络人所有资讯全部的内容,包括:android如何获取联络人所有资讯、Android 5.0 SEAndroid下怎么获得对一个内核节点的访问权限、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9345032.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存