Pregunta

I used <uses-permission android:name="android.permission.READ_CONTACTS" /> and

<uses-feature android:name="android.hardware.telephony" android:required="false" /> in my application's manifest. And read the user's contacts

Intent intent = new Intent(Intent.ACTION_PICK,Contacts.CONTENT_URI);
startActivityForResult(intent,1000);

Does READ_CONTACTS permission can filter the application in Google Play?

What happens if we tried to access the Contacts if there is no Contacts .For eg: Some tablets does not have Contacts and Phone functionality.What happens in this case? Does this code will crash?

If code will cash then how to check whether device supports contacts or not?

Thanks in Advance

¿Fue útil?

Solución

You need to check, if there is an activity to handle the Intent:

Context context = /* whatever suits your case: this/getActivity/.. */
Intent intent = new Intent(Intent.ACTION_PICK,Contacts.CONTENT_URI);
if (intent.resolveActivity(context.getPackageManager()) != null) {
     startActivityForResult(intent,1000);
} else {
     // no Contacts app available
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top