Call contacts app

I want to be able to open the on-phone contacts app by clicking on a button in my sketch.
I am mainly looking for packages to getting the code of the first answer to work.

I am used to working with the android permissions and already allowed the access to storage and to read and write of contacts(even though I don’t need it).

Thanks in advance

If you really want to keep it simple; just names and phone numbers.
Tested with APDE Kitkat 4.4 and Lollipop 5.1 using permission
You know how to place Android buttons?
If not see templates on my repo here.

import android.database.Cursor;
import android.content.ContentResolver;
import android.provider.ContactsContract;

Activity act;

void setup() {
  act = this.getActivity(); 
  Cursor phones = act.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
  while (phones.moveToNext()) {
    String contactName=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
    String contactNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  print(contactName+"  ");
1 Like

Wow, exactly what I was looking for.

Do you want to dial the number also?

Yes, I want to be able to dial a number and send sms.

Are you going to implement all this gigantic amount of code?

import android.database.Cursor;
import android.content.Intent;

void setup() {
  Uri number = Uri.parse("tel:123456789");
  Intent callIntent = new Intent(Intent.ACTION_DIAL, number);

I started copy-pasting your code and then got this error:
Do you know how to fix this?

And if you comment this import?
What android version are you using?

commented the error and ran the code, works fine, thanks.
Android version is 6.0.1, so rather old

Here is how to send a msg.
I, unfortunately, could not test it because I get the warning “You have no credits.” :smiley:
If you have some time please cheque my templates on repo for errors.
Needs permission SEND_SMS

import android.database.Cursor;
import android.content.Intent;
import android.telephony.SmsManager;

String phone_number = "81984763036";
String send_message = "Happy birthday";

void setup() {
  try {
    SmsManager sms = SmsManager.getDefault(); 
    sms.sendTextMessage(phone_number, null, send_message, null, null);
  catch (Exception e) {
    println ("Sms not Send");

Thanks again for your help.

I will but I’m probably not gonna be a lot of help.