Delphi读取Android设备联系人.DelphiXE6中编译通过

和某牛讨论Delphi读Android联系人.写了如下代码

uses
  FMX.Helpers.Android,
  Androidapi.JNI.JavaTypes, Androidapi.JNI.GraphicsContentViewText,
  FMX.Platform.Android, Androidapi.JNIBridge, Androidapi.JNI.Provider,
  Androidapi.Helpers;

procedure QueryContact(AName: string; AList: TStrings);
var
  cursorContactsPhone: JCursor;
  selection: string;
  projection: TJavaObjectArray<JString>;
  FieldIndex: Integer;
begin
  if AList <> nil then
    AList.Clear;
  projection := nil;
  if AName.Length > 0 then
  begin
    projection := TJavaObjectArray<JString>.Create(1);
    projection.Items[0] := TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME;
    selection := JStringToString(TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME)+' LIKE "%' + AName + '%"';
  end;

  //select projection from 联系人数据库 where  selection
  cursorContactsPhone := SharedActivity.getContentResolver.query
    (TJCommonDataKinds_Phone.JavaClass.CONTENT_URI,
    projection {要查询的字段名,nil的全部},
    StringToJString(selection){Where条件},
    nil { 这里是Where语句的条件参数们,我上面图方便,写死在Where条件中了,没使用参数 } , nil);
  if AList <> nil then
    while (cursorContactsPhone.moveToNext) do
    begin
      //获取字段的ColumnIndex
      FieldIndex := cursorContactsPhone.getColumnIndex
        (TJContacts_PeopleColumns.JavaClass.DISPLAY_NAME);
      //读字段内容
      AList.Add(JStringToString(cursorContactsPhone.getString(FieldIndex)));
    end;
  cursorContactsPhone.close;
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  s: TStrings;
begin
  s := TStringList.Create;
  QueryContact('王', s); //查询姓王的人
  ShowMessage(s.Text);
  s.Free;
end;

我是个懒人,不想再深究了.
对了,别忘了Android有权限,加上读取联系人的权限

此条目发表在Delphi, 未分类分类目录,贴了, , , 标签。将固定链接加入收藏夹。

Delphi读取Android设备联系人.DelphiXE6中编译通过》有 99 条评论

  1. 匿名说:

    大牛出个论文不容易啊,顶

  2. Pingback引用通告: Delphi读取Android设备联系人 - 印象派

  3. Pingback引用通告: 2020-2020-2020

  4. Pingback引用通告: wwin-tv.com

  5. Pingback引用通告: hs;br

  6. Pingback引用通告: tureckie_serialy_na_russkom_jazyke

  7. Pingback引用通告: tureckie_serialy

  8. Pingback引用通告: +1+

  9. Pingback引用通告: æóêè+2+ñåðèÿ

  10. Pingback引用通告: Ñìîòðåòü ñåðèàëû îíëàéí âñå ñåðèè ïîäðÿä

  11. Pingback引用通告: Ñìîòðåòü âñå ñåðèè ïîäðÿä

  12. Pingback引用通告: watch

  13. Pingback引用通告: ++++++

  14. Pingback引用通告: HD-720

  15. Pingback引用通告: guardians+of+the+galaxy+2

  16. Pingback引用通告: strong woman do bong soon

  17. Pingback引用通告: my id is gangnam beauty

  18. Pingback引用通告: 2020

  19. Pingback引用通告: kpop+star+season+6+ep+9

  20. Pingback引用通告: Video

  21. Pingback引用通告: 1 2 3 4 5 6 7 8 9 10

  22. Pingback引用通告: Watch TV Shows

  23. Pingback引用通告: Kinokrad 2019 Kinokrad Hd

  24. Pingback引用通告: serial 1

  25. Pingback引用通告: serial

  26. Pingback引用通告: youtube2019.ru

  27. Pingback引用通告: lostfilmtv net

  28. Pingback引用通告: movies

  29. Pingback引用通告: trustedmdstorefy.com

  30. Pingback引用通告: Êîíñóëüòàöèÿ ïñèõîëîãà

  31. Pingback引用通告: topedstoreusa.com

  32. Pingback引用通告: hqcialismht.com

  33. Pingback引用通告: viagramdtrustser.com

  34. Pingback引用通告: Evil-Season-2

  35. Pingback引用通告: 1plus1tv

  36. Pingback引用通告: #1plus1

  37. Pingback引用通告: Watch Movies Online

  38. Pingback引用通告: Film 2020

  39. Pingback引用通告: human design

  40. Pingback引用通告: DSmlka

  41. Pingback引用通告: viagra

  42. Pingback引用通告: viagra online

  43. Pingback引用通告: +

  44. Pingback引用通告: ¯jak Son³k

  45. Pingback引用通告: astrolog

  46. Pingback引用通告: film-kalashnikov-watch

  47. Pingback引用通告: generic cialis

  48. Pingback引用通告: cialis 20mg

  49. Pingback引用通告: kinoxaxru.ru

  50. Pingback引用通告: pobachennya u vegas

  51. Pingback引用通告: strelcov 2020

  52. Pingback引用通告: film t-34

  53. Pingback引用通告: online pharmacy

  54. Pingback引用通告: canadian pharmacy

  55. Pingback引用通告: Beograd film 2020

  56. Pingback引用通告: psiholog

  57. Pingback引用通告: psixolog

  58. Pingback引用通告: psyhelp_on_line

  59. Pingback引用通告: coronavirus

  60. Pingback引用通告: PSYCHOSOCIAL

  61. Pingback引用通告: rasstanovka hellinger

  62. Pingback引用通告: Cherekasi film 2020

  63. Pingback引用通告: film doktor_liza

  64. Pingback引用通告: djoker film

  65. Pingback引用通告: t.me/psyhell

  66. Pingback引用通告: Ïñèõîëîã îíëàéí

  67. Pingback引用通告: bitly.com

  68. Pingback引用通告: viagra 100mg

  69. Pingback引用通告: viagra price

  70. Pingback引用通告: viagra generic

  71. Pingback引用通告: viagra coupon

  72. Pingback引用通告: cheap viagra

  73. Pingback引用通告: cialis

  74. Pingback引用通告: cialis coupon

  75. Pingback引用通告: canadian pharmacy cialis

  76. Pingback引用通告: cialis 5mg

  77. Pingback引用通告: rlowcostmd.com

  78. Pingback引用通告: bitly

  79. Pingback引用通告: movies-tekstmovies-tekst

  80. Pingback引用通告: Zemlyane 2005 smotret onlajn

  81. Pingback引用通告: smotret onlajn v horoshem kachestve hd

  82. Pingback引用通告: gusmeasu.com

  83. Pingback引用通告: movies-unhinged-film

  84. Pingback引用通告: malenkie-zhenshhiny-2020

  85. Pingback引用通告: dom 2

  86. Pingback引用通告: zoom-psykholog

  87. Pingback引用通告: zoom-viber-skype

  88. Pingback引用通告: Vratar Galaktiki Film, 2020

  89. Pingback引用通告: Vratar

  90. Pingback引用通告: Cherkassy 2020

  91. Pingback引用通告: chernobyl-hbo-2019-1-sezon

  92. Pingback引用通告: moskva-psiholog

  93. Pingback引用通告: batmanapollo.ru

  94. Pingback引用通告: 323

  95. Pingback引用通告: 525

  96. Pingback引用通告: dom2-ru

  97. Pingback引用通告: Tenet Online

  98. Pingback引用通告: psy psy psy psy

发表评论

电子邮件地址不会被公开。

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

你必须启用JavaScript