문제

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

도움이 되었습니까?

해결책

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top