2011-05-13 1 views
2

이 의도는 주소 정보가있는 항목을 포함, 연락처를 엽니 다 : 나는 이메일 포함 된 연락처를 필터링이 패턴을 사용하려고했다Android : eMail 연락처를 시작하는 방법?

이제
Intent getContactIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI); 

:

Intent getContactIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI); 

을하지만이 excepts (NO 의도를위한 action_pick)

어떻게 할 수 있습니까?

답변

3

현재는 기본 연락처 응용 프로그램과 함께 할 수 없습니다 기본 연락처 응용 프로그램 등록이 의도 필터 (라인 165 https://android.googlesource.com/platform/packages/apps/Contacts/+/master/AndroidManifest.xml#165에서 참조)

<intent-filter> 
       <action android:name="android.intent.action.PICK" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
       <data android:mimeType="vnd.android.cursor.dir/contact" /> 
       <data android:mimeType="vnd.android.cursor.dir/person" /> 
       <data android:mimeType="vnd.android.cursor.dir/phone_v2" /> 
       <data android:mimeType="vnd.android.cursor.dir/phone" /> 
       <data android:mimeType="vnd.android.cursor.dir/postal-address_v2" /> 
       <data android:mimeType="vnd.android.cursor.dir/postal-address" /> 
      </intent-filter> 

을 그래서 우편 주소로 ACTION_PICK 의도를 응답 할 수있다, 이메일 주소는 ACTION_PICK입니다.

전자 메일 주소 선택을 수행하려면 전자 메일 주소가있는 사용자 만 표시하고 사용자가 선택하기 위해 ListView에 표시하는 연락처 공급자로부터 커서를 가져 오는 자신의 활동을 만들어야합니다.

+0

좋은 설명, 감사합니다! – decades

+0

api가 vime.android.cursor.item/email_v2를 MIME 형식으로 지원하는 @Femi? – Hades

0

이 시도 :

 public void readcontact(){ 
      try { 
       Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); 
       intent.setType("vnd.android.cursor.dir/email"); 
       startActivityForResult(intent, PICK_CONTACT); 
      } catch (Exception e) { 
        e.printStackTrace(); 
       } 
     } 
+0

이것은 예외를 던졌습니다. android.content.ActivityNotFoundException : 인 텐트를 처리 할 활동이 없습니다. {act = android.intent.action.PICK typ = vnd.android.cursor.dir/email}' – ticofab