[Lazarus] using Android SmsManager APIs from Lazarus

duilio foschi octopushole at gmail.com
Fri Jun 2 19:18:40 CEST 2017


I could compile my first Lazarus "hello world" application for Android.

When I click a button on screen, the message "hello world" is displayed.

So far so good.

Now I'd like to make things harder.

When I click the same button on screen, I want text "hello world" be
sent to a predefined mobile number using Android APIs.

I found this example... It seems easy...but it is no pascal!
>>>>>
public void sendSMS(String phoneNo, String msg) {
    try {
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(phoneNo, null, msg, null, null);
        Toast.makeText(getApplicationContext(), "Message Sent",
              Toast.LENGTH_LONG).show();
    } catch (Exception ex) {
        Toast.makeText(getApplicationContext(),ex.getMessage().toString(),
              Toast.LENGTH_LONG).show();
        ex.printStackTrace();
    }
}

<<<<<<

Is there a way to use Android APIs from Lazarus ?

Thank you

Peppe Polpo


More information about the Lazarus mailing list