关于 DelphiXE 5/6/7 安卓读取通话记录的办法

Google 了半天,硬是没发现有人做过,那唯有自己翻译了一个,DelphiXE7 测试通过

var
cr: JContentResolver;
projection: TJavaObjectArray<JString>;
Cursor: JCursor;
i: Integer;
begin
cr:= SharedActivity.getContentResolver;
projection:= TJavaObjectArray<JString>.Create(5);
projection.Items[0]:= TJCallLog_Calls.JavaClass.NUMBER;
projection.Items[1]:= TJCallLog_Calls.JavaClass.CACHED_NAME;
projection.Items[2]:= TJCallLog_Calls.JavaClass.&TYPE;
projection.Items[3]:= TJCallLog_Calls.JavaClass.DATE;
projection.Items[4]:= TJCallLog_Calls.JavaClass.DURATION;
Cursor:= cr.query(TJCallLog_Calls.JavaClass.CONTENT_URI, projection, nil, nil, TJCallLog_Calls.JavaClass.DEFAULT_SORT_ORDER);

for i:= 0 to Cursor.getCount – 1 do
begin
Cursor.moveToPosition(i);
ShowMessage(JStringToString(Cursor.getString(0))); //电话号码
end;

projection.Free;
end;

关于 DelphiXE 5/6/7 安卓读取通话记录的办法》有1个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注