Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkey

Read SMS Messages With The JNI API In Delphi XE6 Firemonkey on Android

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE6 Firemonkey Read SMS Android | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Developer Andrey Yefimov has a blog post up where he demonstrates how to read a list of SMS messages into Delphi XE6 Firemonkey using the Android API. We’ve covered reading and writing SMS messages on Android before a few months ago. Andrey explains that you need to add the Read SMS permission to your Android manifest for in order for your app to read SMS messages. He also explains that SMS messages are stored in directories on your Android device using local databases. There is sample code where he shows how to find and read these files using the Android SDK and the Delphi Firemonkey JNI. The demo app includes a list of URIs (like content://sms) to the location of the SMS messages and the source code resolves the URI to the actual location. The code then loops through the location using a JCursor object and read each item like so:Ā JStringToString(cursor.getString(
cursor.getColumnIndex(StringToJString(‘ADDRESS’)))); I think you can see a list of all of the columns in this Object Pascal Android interface file:
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_ALL = 0;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_INBOX = 1;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_SENT = 2;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_DRAFT = 3;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_OUTBOX = 4;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_FAILED = 5;
TJTelephony_TextBasedSmsColumnsMESSAGE_TYPE_QUEUED = 6;
TJTelephony_TextBasedSmsColumnsTYPE = 'type';
TJTelephony_TextBasedSmsColumnsTHREAD_ID = 'thread_id';
TJTelephony_TextBasedSmsColumnsADDRESS = 'address';
TJTelephony_TextBasedSmsColumnsDATE = 'date';
TJTelephony_TextBasedSmsColumnsDATE_SENT = 'date_sent';
TJTelephony_TextBasedSmsColumnsREAD = 'read';
TJTelephony_TextBasedSmsColumnsSEEN = 'seen';
TJTelephony_TextBasedSmsColumnsSTATUS = 'status';
TJTelephony_TextBasedSmsColumnsSTATUS_NONE = -1;
TJTelephony_TextBasedSmsColumnsSTATUS_COMPLETE = 0;
TJTelephony_TextBasedSmsColumnsSTATUS_PENDING = 32;
TJTelephony_TextBasedSmsColumnsSTATUS_FAILED = 64;
TJTelephony_TextBasedSmsColumnsSUBJECT = 'subject';
TJTelephony_TextBasedSmsColumnsBODY = 'body';
TJTelephony_TextBasedSmsColumnsPERSON = 'person';
TJTelephony_TextBasedSmsColumnsPROTOCOL = 'protocol';
TJTelephony_TextBasedSmsColumnsREPLY_PATH_PRESENT = 'reply_path_present';
TJTelephony_TextBasedSmsColumnsSERVICE_CENTER = 'service_center';
TJTelephony_TextBasedSmsColumnsLOCKED = 'locked';
TJTelephony_TextBasedSmsColumnsERROR_CODE = 'error_code';

Andrey’s blog is in Russian but you should be able to use Google Chrome to translate it to your language.
Head over and check out the full blog post for yourself about how to read SMS messages with Delphi XE6 Firemonkey.

OrĀ download a mirror of the Read SMS demo for Delphi XE6 Firemonkey


Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts

How To Build Stable Diffusion Text To Image Prompts


FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes


Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores


DelphiCon 2020 FireMonkey Sessions Available Starting November 19

Sign up for our Newsletter and
stay informed

Leave a Reply