1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

How to fetch SMS messages from the Android inbox using Delphi

Discussion in 'Delphi Android And IOS' started by AdminDF, Feb 2, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    The code speaks for itself:


    Code:
    uses
      SysUtils,
      FMX.Helpers.Android,
      Androidapi.JNI.GraphicsContentViewText,
      Androidapi.JNI.Net,
      Androidapi.JNI.JavaTypes,
      Androidapi.JNI.Telephony;
    
    function FetchSms:string;
    var
      cursor: JCursor;
      uri: Jnet_Uri;
      address,person,msgdatesent,protocol,msgread,msgstatus,msgtype,
      msgreplypathpresent,subject,body,
      servicecenter,HIDE-THANKSed:string;
      msgunixtimestampms:int64;
      addressidx,personidx,msgdateidx,msgdatesentidx,protocolidx,msgreadidx,
      msgstatusidx,msgtypeidx,msgreplypathpresentidx,subjectidx,bodyidx,
      servicecenteridx,HIDE-THANKSedidx:integer;
    begin
      uri:=StrToJURI('content://sms/inbox');
      cursor := SharedActivity.getContentResolver.query(uri, nil, nil,nil,nil);
      addressidx:=cursor.getColumnIndex(StringToJstring('address'));
      personidx:=cursor.getColumnIndex(StringToJstring('person'));
      msgdateidx:=cursor.getColumnIndex(StringToJstring('date'));
      msgdatesentidx:=cursor.getColumnIndex(StringToJstring('date_sent'));
      protocolidx:=cursor.getColumnIndex(StringToJstring('protocol'));
      msgreadidx:=cursor.getColumnIndex(StringToJstring('read'));
      msgstatusidx:=cursor.getColumnIndex(StringToJstring('status'));
      msgtypeidx:=cursor.getColumnIndex(StringToJstring('type'));
      msgreplypathpresentidx:=cursor.getColumnIndex(StringToJstring('reply_path_present'));
      subjectidx:=cursor.getColumnIndex(StringToJstring('subject'));
      bodyidx:=cursor.getColumnIndex(StringToJstring('body'));
      servicecenteridx:=cursor.getColumnIndex(StringToJstring('service_center'));
      HIDE-THANKSedidx:=cursor.getColumnIndex(StringToJstring('HIDE-THANKSed'));
      while (cursor.moveToNext) do begin
        address:=JStringToString(cursor.getString(addressidx));
        person:=JStringToString(cursor.getString(personidx));
        msgunixtimestampms:=cursor.getLong(msgdateidx);
        msgdatesent:=JStringToString(cursor.getString(msgdatesentidx));
        protocol:=JStringToString(cursor.getString(protocolidx));
        msgread:=JStringToString(cursor.getString(msgreadidx));
        msgstatus:=JStringToString(cursor.getString(msgstatusidx));
        msgtype:=JStringToString(cursor.getString(msgtypeidx));
        msgreplypathpresent:=JStringToString(cursor.getString(msgreplypathpresentidx));
        subject:=JStringToString(cursor.getString(subjectidx));
        body:=JStringToString(cursor.getString(bodyidx));
        servicecenter:=JStringToString(cursor.getString(servicecenteridx));
        HIDE-THANKSed:=JStringToString(cursor.getString(HIDE-THANKSedidx));
        Result:=IntToStr(trunc(msgunixtimestampms/1000))+' '+address+' '+body;
      end;
    end;
    
     

Share This Page