How Do You Test For ContactPicker NOT Returning Data?

How can I test for the condition where the user has returned from the ContactPicker without selecting a contact in the list? In other words, AfterPicking does not fire because there is nothing selected.

Assuming this would also be an issue for any other list picker.

Are you sure that is true Bob? It should return an 'empty text' and you can test by verifying the text length.

I'll give it a try.

Is ContactPicker returning text or a list?

........Test the length of the text (it's not a List)

A button that, when clicked on, displays a list of the contacts to choose among. After the user has made a selection, the following properties will be set to information about the chosen contact:

  • ContactName : the contact’s name
  • EmailAddress : the contact’s primary email address
  • EmailAddressList : a list of the contact’s email addresses
  • ContactUri : the contact’s URI on the device
  • PhoneNumber : the contact’s primary phone number (on Later Android Verisons)
  • PhoneNumberList : a list of the contact’s phone numbers (on Later Android Versions)
  • Picture : the name of the file containing the contact’s image, which can be used as a Picture property value for the Image or ImageSprite component.

Other properties affect the appearance of the button ( TextAlignment , BackgroundColor , etc.) and whether it can be clicked on ( Enabled ).

The ContactPicker component might not work on all phones. For example, on Android systems before system 3.0, it cannot pick phone numbers, and the list of email addresses will contain only one email.

Note, since it is in an external shared folder, it may be the case that App Inventor nb187c isn't interacting properly. There are a number of issues with external files (Google has tightened Security), nb187d should fix them.

Running Android 11(API:30)

Contact Picker IS working. Here's my desire:

[Select Contact] button is visible
[Add/Edit Contacts] button is invisible
If user does not select a contact, I want the [Select Contact] button to go invisible and the [Add/Edit Contacts] button to go visible.
The reverse process is working because the AfterActivity function handles the user return.

I'll try the length test.


I wouldn't advise making controls disappear, Users find that unnerving - you wouldn't want your fuel gauge to disappear from your car dashboard whilst driving on the motorway :upside_down_face:

Only way I could think of to change the button activity, and since I'm the only user... :grin:

...just disable the button :grin:

Trying to conserve screen space...realize that I could add another button to the side to handle the add/edit feature, but then it screws up the feng shui of the screen. :relaxed:

Those code blocks are working for you?
If I select a contact, it works, if I don't, then nothing.

Here's what I created on a new project:

...which has the Notifers the wrong way round.

Not that the notifiers really mattered because if I didn't select a contact, no notifier appeared.

... but you are right. the .AfterPicking event is only triggered if a pick was made :thinking: how about the same test, but using the LostFocus event instead - the focus is lost if the User makes a Pick, or does not.

Like this?

Nope. Didn't work.

In what way does it not work? Have you added a Notifier component to the same screen.