Retrieve contact list in Sketchware

 To read contact list in Sketchware pro, follow the steps given below.

1. In the Sketchware project, in main.xml, add a ListView. Also add a custom view for ListView items. For the ListView, select the custom view.

2. Switch on AppCompat and design.

3. In permission manager, select android.permission.READ_CONTACTS.

4. In Activity, add Import event. Put following codes in the import event:


5. Create a more block getAllContacts of type List Map. In this more block, put following codes:


In above code, the name and number of contacts is retrieved and added to a map variable using keys "name" and "number". This map variable is added to a Map list, which is returned as the result.

6. Create another more block readContacts of type regular (Void). In this more block, put following blocks which retrieve contacts and display in ListView:


7. In onBindCustomView, add blocks to display the name and number.
8. In onCreate, put codes to Check READ_CONTACTS permissions. If permission granted, use _readContacts() to get contacts and display them. If permission is not granted, request READ_CONTACTS permission.



9. For onRequestPermissionsResult, put following codes in last block in onCreate:



10. Save and run the project.

Watch videos below for better understanding.









Comments

Popular posts from this blog

Simple car racing android game in Sketchware

How to enable upload from webview in Sketchware?

Enable Fullscreen for Youtube videos in WebView

Creating a Drawing View in Sketchware

List of Calendar Format symbols valid in Sketchware