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);

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值