0

有人可以提供将联系人从 sdcard 导入到 Android 手机的代码吗?我正在查看此链接: Export the Contacts as VCF file 然而,它与我想要的相反。请帮忙。

4

1 回答 1

0

为了导入联系人,您只需要调用 Android 的内置 Intent ....

 private void restoreContact(){
   if(android.os.Build.VERSION.SDK_INT < 11){
      try{
           Intent i = new Intent();
           i.setComponent(new ComponentName("com.android.contacts","com.android.contacts.ImportVCardActivity"));
           startActivity(i);
       } catch(Exception e){
           try {
               Intent i = new Intent();
               i.setComponent(new ComponentName("com.sonyericsson.contacts","com.sonyericsson.contacts.contactlist.ImportVCardActivity"));
               startActivity(i);
           }
           catch (Exception ex)
           {
            //Show Exception

           }
       }

  } else if(android.os.Build.VERSION.SDK_INT >= 11){
      try{
           Intent intent =new Intent();
           intent.setComponent(new ComponentName("com.android.contacts","com.android.contacts.vcard.ImportVCardActivity"));
           startActivity(intent);
      }catch(Exception e){
        //Show Exception

       }          
    }
 }
于 2013-03-13T08:55:25.380 回答