国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

手機聯系人權限 - 獲取手機聯系人

2019-11-08 00:38:26
字體:
來源:轉載
供稿:網友
/* * 檢查聯系人權限 */ PRivate void getPhone() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { //如果沒有授權,則請求授權 ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_CALL_CAMERA); } else { //有授權 getPerson(ImportKinsfolkActivity.this); } } /** * 遍歷手機聯系人 * * @param context * @return */ public String getPerson(Context context) { String ConstrantsJson = ""; // JSONObject jsonObject = new JSONObject(); JSONArray array = new JSONArray(); Cursor cursor = context.getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); jobjList = new ArrayList<>(); while (cursor.moveToNext()) { int indexPeopleName = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); int indexPhoneNum = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); String strPeopleName = cursor.getString(indexPeopleName).replace(" ", ""); String strPhoneNum = cursor.getString(indexPhoneNum).replace(" ", ""); if (Tools.isMobileNO(strPhoneNum)) { ImportKinsfolkBean bean = new ImportKinsfolkBean(); bean.name = strPeopleName; bean.phone = strPhoneNum; mList.add(bean);// JSONObject jsonObjectItem = new JSONObject();// try {// jsonObjectItem.put("Name", strPeopleName);// jsonObjectItem.put("Phone", strPhoneNum);// array.put(jsonObjectItem);// jobjList.add(jsonObjectItem);// } catch (Exception e) {// } } } if (!cursor.isClosed()) { cursor.close(); cursor = null; } ConstrantsJson = array.toString();// invite_array = array;// if(array.length() > 500) {// invite_num = Math.ceil(array.length() / 500.0);// } tv_num.setText("發現"+mNum+"條疑似親人記錄"); return ConstrantsJson; }
上一篇:FindBugs日記

下一篇:Canvas - 畫布.md

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙江县| 安溪县| 宣汉县| 陕西省| 上高县| 监利县| 北票市| 荃湾区| 慈溪市| 仲巴县| 旌德县| 慈溪市| 高青县| 原阳县| 旺苍县| 汶川县| 苏尼特右旗| 读书| 怀仁县| 介休市| 高密市| 漳浦县| 蒙城县| 房山区| 丽水市| 沐川县| 鲁山县| 株洲县| 宜宾市| 义乌市| 沾益县| 济宁市| 江山市| 栾川县| 枞阳县| 杭锦后旗| 永靖县| 扎鲁特旗| 拉萨市| 突泉县| 蓬莱市|