Jump to content
Janex72

Sending SMS via FMX application

Recommended Posts

Hi all.

I'm sending SMS to my phone number from my application in this way:

Procedure _SendSMS (Target, Messagestr :String);
Var smsManager :JSmsManager;
    smsTo      :JString;
begin
  smsManager := TJSmsManager.JavaClass.getDefault;
  smsTo      := StringToJString(target);
  smsManager.sendTextMessage(smsTo, Nil, StringToJString(messagestr), Nil, Nil);
End;

SMS sent ok and returned ok to, now I look in content://sms/sent

 

Uri          := StrToJURI('content://sms/sent');
Cursor       := SharedActivity.GetContentResolver.query(Uri, Nil, Nil, Nil, Nil);
Date_SentIdx := Cursor.GetColumnIndex(StringToJstring('date_sent'));
StatusIdx    := Cursor.GetColumnIndex(StringToJstring('status'));
While (Cursor.MoveToNext) Do Begin
  Date_Sent := JStringToString(Cursor.getString(Date_SentIdx ));
  Status    := Cursor.getInt(StatusIdx);
End;

and there I have a big problem - field date_sent  always is empty :(

If I send SMS to non-existent number the field status always is -1.

If I send the same SMS via standart Phone SMS application all is ok - field date_sent is not empty

and field status contain error code (if I send to non-existent number)

 

Android 7.0

Delphi 10.4.2

Android API Level 24

Any idea how to send SMS from my application and get filled fields  date_sent  and status ?

 

WBR

Janex

 

 

 

 

 

 

 

 

 

Share this post


Link to post

I'm informed about this link in StackOverflow, but unfortunately via SharedActivity.GetContentResolver we have not field report_date  😞

 

WBR

Janex

Share this post


Link to post
5 hours ago, Janex72 said:

unfortunately via SharedActivity.GetContentResolver we have not field report_date  😞

You should be able to simply replace this:

Date_SentIdx := Cursor.GetColumnIndex(StringToJstring('date_sent'));

with this:

Date_SentIdx := Cursor.GetColumnIndex(StringToJstring('report_date'));

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×