http://www.youtube.com/watch?v=I6ObTqIiYfE
视频中使用的SDK是比较早的版本,有些API已经改了。
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // setContentView(R.layout.main);
- Cursor c = this.getContentResolver().query(People.CONTENT_URI, null, null, null, null);
- this.startManagingCursor(c);
- String[] columns = new String[] { People.NAME };
- int[] names = new int[] { R.id.row_entry };
- mAdapter = new SimpleCursorAdapter(this, R.layout.main, c, columns, names);
- this.setListAdapter(mAdapter);
- }
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- super.onListItemClick(l, v, position, id);
- Intent intentCall = new Intent(Intent.ACTION_CALL);
- Cursor c = (Cursor) mAdapter.getItem(position);
- String phoneId = c.getString(c.getColumnIndex(People.PRIMARY_PHONE_ID));
- intentCall.setData(Uri.withAppendedPath(Phones.CONTENT_URI, phoneId));
- startActivity(intentCall);
- }