Delphi读取android短信信息


本文整理自网络,侵删。

 
//要加入读取权限 菜单project--option--Uses Permissions--read sms改为true
procedure TForm1.Button1Click(Sender: TObject);
begin
  Button1.Visible := False;
  Detail2xiaoxiTabAction.ExecuteTarget(self);
end;
procedure TForm1.ListBox1ItemClick(const Sender: TCustomListBox;
  const Item: TListBoxItem);
begin
Memo1.Lines.Clear;
  Memo1.Lines.Add(ListBox1.Selected.ItemData.Text + #13#10#13#10 +
    ListBox1.Selected.ItemData.Detail);
  Button1.Visible := true;
  xiaoxi2detailTabAction.ExecuteTarget(self);
end;
procedure TForm1.Text1Click(Sender: TObject);//uses Androidapi.JNI.GraphicsContentViewText,Androidapi.Helpers
var
  cursor: JCursor;
  SMSListBoxItem: TListBoxItem;
begin
  ListBox1.Clear;
  AniIndicator1.Enabled:=True;
  AniIndicator1.Visible:=True;
  TabControl1.TabIndex := 0;
  Application.ProcessMessages;
  ListBox1.BeginUpdate;
  try
    cursor := TAndroidHelper.Activity.getContentResolver.query
      (StrToJURI('content://sms'), nil, nil, nil, nil);
    if (cursor.getCount > 0) then
    begin
      while (cursor.moveToNext) do
      begin
        SMSListBoxItem := TListBoxItem.Create(ListBox1);
        SMSListBoxItem.StyleLookup := 'listboxitemrightdetail';
        SMSListBoxItem.ItemData.Accessory := TListBoxItemData.TAccessory.aMore;
        SMSListBoxItem.ItemData.Text :=
          JStringToString
          (cursor.getString(cursor.getColumnIndex(StringToJString('ADDRESS'))));
        SMSListBoxItem.ItemData.Detail :=
          JStringToString
          (cursor.getString(cursor.getColumnIndex(StringToJString('body'))));
        ListBox1.AddObject(SMSListBoxItem);
      end;
    end;
  finally
    cursor.close;
    ListBox1.EndUpdate;
  end;
  AniIndicator1.Enabled:=False;
  AniIndicator1.Visible:=False;
end;

相关阅读 >>

Delphi sizetostr 文件大小转换kb mb gb tb

Delphi uac相关代码

Delphi复制文件时,如何显示进度条

Delphi inttohex 查看字符的十六进制值

Delphi中关闭“返回值…可能未定义”的警告

Delphi 使用泛型的 tarray 从动态数组中查找指定元素

Delphi 中的文件系统进行unicode标准化

Delphi 过滤字符串首位特殊符号

Delphi2010读取mysql数据库text类型乱码的解决方案

Delphi 得到指定文件夹内文件名

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...