I have an intent
final Intent pickContact = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
mSuspectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(pickContact, REQUEST_CONTACT);
}
});
and checking existing of the activities that can handle it
if(packageManager.resolveActivity(pickContact, PackageManager.MATCH_DEFAULT_ONLY) == null)
mSuspectButton.setEnabled(false);
When i run this app on an emulator with API 32, because it has a contact app, resolveActivity() can find the needed activity to run. But then i tried to run this app on my phone with API 30 and resolveActivity() didn't find any activities to run and the button was blocked despite it has the default contact app. Then i commented lines with resolveActivity()
//if(packageManager.resolveActivity(pickContact, PackageManager.MATCH_DEFAULT_ONLY) == null)
// mSuspectButton.setEnabled(false);
and tried to run the app on my phone again expecting that when i press the button my app will crush. But to my surprise when i pressed it the app found the needed activity and ran it.
Why can't resolveActivity() find the activity on my phone?