코드 하이라이트가 사파리에서는 이상한가요??
아니점 제가 사용법을 모르는건가요..ㅠ.ㅠ
자꾸 왜 줄이 새로 생겨버리는지..
인텐트를 보내면 전화번호부가 나오게 됩니다.
여기에서 하나의 항목을 선택하면 그 항목의 절대주소(?)가 data.getDataString() 로 넘어옵니다.
대략
content://com.android.contacts/data/555
같은 형식이지요.
여기에 담긴 String 데이터를 어떻게 뽑아올수 있는건가요??
========================================================
public class ExampleContactMain extends Activity {
private static final String LOG = "ExampleContactMain";
protected static final int REQUEST_CODE = 0;
private TextView name, phone;
private Button btnGetContact;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initSetting();
eventSetting();
}
private void eventSetting() {
btnGetContact.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Intent intent = new Intent(ExampleContactMain.this,
// ExampleContactList.class);
// startActivity(intent);
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setData(Uri.parse("content://com.android.contacts/data/phones"));
startActivityForResult(intent, REQUEST_CODE);
}
});
}
private void initSetting() {
name = (TextView) findViewById(R.id.textView2);
phone = (TextView) findViewById(R.id.textView4);
btnGetContact = (Button) findViewById(R.id.button1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Log.d(LOG, data.getData() + "");
}
}
}
}
========================================================
위의 content://com.android.contacts/data/555는 URI 라고해서 실제 데이타의 주소 즉, 실제 contact DB안의 주소입니다.
위 URI를 가지고 DB 쿼리를 직접 하셔야 합니다. DB 쿼리문까지 댓글에 올릴 필요는 없을 것 같습니다.