红鱼儿

FetchSms
function FetchSms(sender:string):string;
var
  cursor: JCursor;
  uri: Jnet_Uri;
  address, msgdatesent, body: string;
  addressidx, msgdatesentidx, bodyidx: integer;
  fMessage: string;
begin
  uri := StrToJURI('content://sms/inbox');
  cursor := TAndroidHelper.Activity.getContentResolver.query(uri, nil, nil,nil,nil);
  addressidx := cursor.getColumnIndex(StringToJstring('address'));
  msgdatesentidx := cursor.getColumnIndex(StringToJstring('date_sent'));
  bodyidx := cursor.getColumnIndex(StringToJstring('body'));
  cursor.moveToFirst;
  while (cursor.moveToNext) do
  begin
    address := JStringToString(cursor.getString(addressidx));
    msgdatesent := JStringToString(cursor.getString(msgdatesentidx));
    body := JStringToString(cursor.getString(bodyidx));
    if UpperCase(address) = UpperCase(sender) then
    begin
      fMessage := msgdatesent+'-'+address+'-'+body;
      Break
    end;
  end;
  Result := fMessage;
end;

 

posted on 2022-11-02 11:10  红鱼儿  阅读(102)  评论(0编辑  收藏  举报