显示联系人以及讲一个联系人添加到组里面或者从联系人中法医一个电话

public Uri addToGroup(long personId, long groupId) { 
 

   
this.removeFromGroup(personId, groupId); 
 
   
ContentValues values = new ContentValues(); 
    values
.put(ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID, 
            personId
); 
    values
.put( 
           
ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID, 
            groupId
); 
    values 
           
.put( 
                   
ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE, 
                   
ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE); 
 
   
return this.ctx.getContentResolver().insert( 
           
ContactsContract.Data.CONTENT_URI, values); 
 
}

 

2

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Cursor contactsCursor = this.managedQuery(People.CONTENT_URI,
null, null, null, null);
    startManagingCursor(contactsCursor);

    String[] columnsToMap = new String[] {People.NAME};
    int[] mapTo = new int[] {android.R.id.text1};

    ListAdapter mAdapter = new SimpleCursorAdapter(this,
    android.R.layout.simple_list_item_1,
contactsCursor, columnsToMap, mapTo);
    this.setListAdapter(mAdapter);

 

3. protected void onListItemClick(ListView l, View v, int position, long id) {
  // GET THE ITEM THAT HAD BEEN TAPPED
  Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, id);
  Cursor c = managedQuery(uri, new String[] {
      People.NUMBER
    }, null, null, null);
  c.moveToFirst();

  // CALL THE NUMBER FROM THE PREVIOUS SCREEN\
  int phoneNumberIndex = c.getColumnIndex(People.NUMBER);
  Uri parsedPhoneNumber = Uri.parse("tel:"+c.getString(phoneNumberIndex));
  Intent i = new Intent(Intent.ACTION_CALL,parsedPhoneNumber);
  startActivity(i);

  super.onListItemClick(l, v, position, id);
}

你可能感兴趣的:(C++,c,android,C#)