0
안드로이드에 연락처에서 데이터 전화를 보낼 코드가 있습니다. 우리가 안드로이드에서 전화 연락 많은 데이터를 알고 있습니다. 내가 전화 연락에서 데이터를 얻기 위해 코드를 가지고 params.add(new BasicNameValuePair("friend", phone));
안드로이드 서버에 배열 데이터 보내기
친구에서이
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " ASC");
int row = cursor.getCount();
friend_item = new MenuItem [row];
int i=0;
while(cursor.moveToNext()){
nama = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
phone = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
friend_item[i] = new MenuItem(nama,phone);
i++;
}
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("phone", mPhoneNumber));
params.add(new BasicNameValuePair("friend", phone));
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(Constants.url_phone_contact, "POST", params);
// Check your log cat for JSON reponse
Log.d("All Friend: ", json.toString());
try {
friend = json.getJSONArray("friend");
friend_item = new MenuItem[friend.length()];
// looping through All Products
for (int a = 0; a < friend.length(); a++) {
JSONObject c = friend.getJSONObject(i);
//Storing each json item in variable
String phone_friend= c.getString(TAG_PHONE);
friend_item[i] = new MenuItem(nama, phone_friend);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put("nama", nama);
map.put("phone", phone_friend);
// adding HashList to ArrayList
friendList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
처럼 목록보기로 표시 데이터 배열, [phone_contact]에서 배열입니다. 그래서 어떻게 안드로이드 서버에 데이터 배열 및 문자열 "mPhoneNumber"보낼 수 있습니까 ?? 덕분에
안드로이드의 새로운 Iam이 같은 데이터를 namevaluepairs에 할당하는 방법은 무엇입니까? –