本文整理自网络,侵删。
//要加入读取权限 菜单project--option--Uses Permissions--read sms改为trueprocedure TForm1.Button1Click(Sender: TObject);begin Button1.Visible := False; Detail2xiaoxiTabAction.ExecuteTarget(self);end;procedure TForm1.ListBox1ItemClick(const Sender: TCustomListBox; const Item: TListBoxItem);beginMemo1.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.Helpersvar 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 结构体的使用、tbitmap和tmemorystream的转换
Delphi 利用unigui中的tunipagecontrol实现多页面
Delphi 10.3 调试程序时出错:unable to create process:请求的操作需要提升
更多相关阅读请进入《Delphi》频道 >>