Contacts中Intent对象的使用

一.跳到所有联系人界面:   

  1. Intent intent = new Intent();  
  2. intent.setAction(Intent.ACTION_VIEW);  
  3. intent.setData(Contacts.People.CONTENT_URI);  
  4. startActivity(intent);

      跳到某个联系人详细信息界面:startActivity(new Intent(Intent.ACTION_VIEW,UriContactsId));在Contacts.People.CONTENT_URI这个Uri的后面加上联系人的ID就行

二.跳到插入一个新的联系人界面

    Intent intent2 = new Intent(Intent.ACTION_INSERT_OR_EDIT); 
            intent2.setType("vnd.android.cursor.item/person");   //数据类型  
            intent2.setType("vnd.android.cursor.item/contact"); 
            intent2.setType("vnd.android.cursor.item/raw_contact"); 
            intent2.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, ""); //值  
            intent2.putExtra(android.provider.ContactsContract.Intents.Insert.COMPANY,"");  
            intent2.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, ""); 
            intent2.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 1);
            startActivity(intent2);

    以上面的方式跳转时,如果你给的值是空的那么跳到界面后编辑也是空的;如果有值穿进去对应的编辑框里面也会填上对应的值

猜你喜欢

转载自blog.csdn.net/u010949962/article/details/17289743