erva
-
Content Count
48 -
Joined
-
Last visited
Posts posted by erva
-
-
I'am evaluating RemObjects Data Abstract and trying to get calculated field to show values at grid components column but it stays empty.
I have in table's OnCalcField event this code:
procedure TClientDataModule.tbl_tasksCalcFields(DataTable: TDADataTable); begin if DataTable.FieldByName('done').AsInteger = 1 then begin DataTable.FieldByName('isDone').AsWideString := 'Open'; end else DataTable.FieldByName('isDone').AsWideString := 'Done'; end;
Also set field calculated property to true.
I tested code above if it's gets executed adding there ShowMessage('Test') and it gets executed.
Haven't been using Delphi 15 years and don't member if there's something that i'am missing in properties etc.....
-
Solved the problem. Code is not "optimised" but works:
CallTimeDouble := StrToInt64(DATEx) / 1000; //Gives seconds
CallTimeDouble := CallTimeDouble / 60; //Gives Minutes
CallTimeDouble := CallTimeDouble / 60; //Gives hours
CallTimeDOuble := CallTimeDouble / 24; //Gives dates
CallTimeDouble := CallTimeDouble + 25569; //01.01.1970 - 30.12.1899
CallTimeDouble := CallTimeDouble + 0.125; //Added +3h to GMT, Finland
Result := CACHED_NAMEx + ' ' + NUMBERx + ' ' + FormatDateTime('dd.mm.yyyy hh:mm:ss', CallTimeDouble) + ' ' + DURATIONx;ShowMessage(Result);
-
I asked same question in Stackoverflow:
There's mentioned that value is number of millisecond since January 1, 1970, 00:00:00 GMT.
This gets complicated....
-
Yes, i get same like results in app with real data with several calls DATEx what comes from call_log.
-
-
I'am reading calls from Android call log. Date format is something that Delhi don't recognise. Date is returned like this: "1587377791601".
Any idea what this number means and how to get date and time from it?
Here's code what works, i have commented out lines what i don't want use. In commented lines is (StringToJString(...)) but it must be ( TJCallLog_Calls.JavaClass....) :
var cursor: JCursor; uri: Jnet_Uri; CACHED_FORMATTED_NUMBER, CACHED_LOOKUP_URI, CACHED_MATCHED_NUMBER, CACHED_NAME, CACHED_NORMALIZED_NUMBER, CACHED_NUMBER_LABEL, CACHED_NUMBER_TYPE, CACHED_PHOTO_ID, CONTENT_ITEM_TYPE, CONTENT_TYPE, COUNTRY_ISO, DATA_USAGE, DATE, DEFAULT_SORT_ORDER, DURATION, EXTRA_CALL_TYPE_FILTER, FEATURES, IS_READ, LIMIT_PARAM_KEY, NEW, NUMBER, NUMBER_PRESENTATION, OFFSET_PARAM_KEY, PHONE_ACCOUNT_COMPONENT_NAME, PHONE_ACCOUNT_ID, TRANSCRIPTION, TYPEX, VOICEMAIL_URI : integer; msgunixtimestampms:int64; CACHED_FORMATTED_NUMBERx, CACHED_LOOKUP_URIx, CACHED_MATCHED_NUMBERx, CACHED_NAMEx, CACHED_NORMALIZED_NUMBERx, CACHED_NUMBER_LABELx, CACHED_NUMBER_TYPEx, CACHED_PHOTO_IDx, CONTENT_ITEM_TYPEx, CONTENT_TYPEx, COUNTRY_ISOx, DATA_USAGEx, DATEx, DEFAULT_SORT_ORDERx, DURATIONx, EXTRA_CALL_TYPE_FILTERx, FEATURESx, IS_READx, LIMIT_PARAM_KEYx, NEWx, NUMBERx, NUMBER_PRESENTATIONx, OFFSET_PARAM_KEYx, PHONE_ACCOUNT_COMPONENT_NAMEx, PHONE_ACCOUNT_IDx, TRANSCRIPTIONx, TYPEXx, VOICEMAIL_URIx : string; CallTime: TDateTime; Result: String; begin uri:=StrToJURI('content://call_log/calls'); cursor := SharedActivity.getContentResolver.query(uri, nil, nil,nil,nil); // CACHED_FORMATTED_NUMBER:=cursor.getColumnIndex(StringToJstring('CACHED_FORMATTED_NUMBER')); // CACHED_LOOKUP_URI:=cursor.getColumnIndex(StringToJstring('CACHED_LOOKUP_URI')); // CACHED_MATCHED_NUMBER:=cursor.getColumnIndex(StringToJstring('CACHED_MATCHED_NUMBER')); CACHED_NAME:=cursor.getColumnIndex( TJCallLog_Calls.JavaClass.CACHED_NAME ); // CACHED_NORMALIZED_NUMBER:=cursor.getColumnIndex(StringToJstring('CACHED_NORMALIZED_NUMBER')); // CACHED_NUMBER_LABEL:=cursor.getColumnIndex(StringToJstring('CACHED_NUMBER_LABEL')); // CACHED_NUMBER_TYPE:=cursor.getColumnIndex(StringToJstring('CACHED_NUMBER_TYPE')); // CACHED_PHOTO_ID:=cursor.getColumnIndex(StringToJstring('CACHED_PHOTO_ID')); // CONTENT_ITEM_TYPE:=cursor.getColumnIndex(StringToJstring('CONTENT_ITEM_TYPE')); // CONTENT_TYPE:=cursor.getColumnIndex(StringToJstring('CONTENT_TYPE')); // COUNTRY_ISO:=cursor.getColumnIndex(StringToJstring('COUNTRY_ISO')); // DATA_USAGE:=cursor.getColumnIndex(StringToJstring('DATA_USAGE')); DATE:=cursor.getColumnIndex( TJCallLog_Calls.JavaClass.DATE ); // DEFAULT_SORT_ORDER:=cursor.getColumnIndex(StringToJstring('DEFAULT_SORT_ORDER')); DURATION:=cursor.getColumnIndex( TJCallLog_Calls.JavaClass.DURATION ); // EXTRA_CALL_TYPE_FILTER:=cursor.getColumnIndex(StringToJstring('EXTRA_CALL_TYPE_FILTER')); // FEATURES:=cursor.getColumnIndex(StringToJstring('FEATURES')); // IS_READ:=cursor.getColumnIndex(StringToJstring('IS_READ')); // LIMIT_PARAM_KEY:=cursor.getColumnIndex(StringToJstring('LIMIT_PARAM_KEY')); // NEW:=cursor.getColumnIndex(StringToJstring('NEW')); // NUMBER:=cursor.getColumnIndex(StringToJstring('NUMBER')); // NUMBER_PRESENTATION:=cursor.getColumnIndex(StringToJstring('NUMBER_PRESENTATION')); // OFFSET_PARAM_KEY:=cursor.getColumnIndex(StringToJstring('OFFSET_PARAM_KEY')); // PHONE_ACCOUNT_COMPONENT_NAME:=cursor.getColumnIndex(StringToJstring('PHONE_ACCOUNT_COMPONENT_NAME')); // PHONE_ACCOUNT_ID:=cursor.getColumnIndex(StringToJstring('PHONE_ACCOUNT_ID')); // NUMBER_PRESENTATION:=cursor.getColumnIndex(StringToJstring('NUMBER_PRESENTATION')); // TRANSCRIPTION:=cursor.getColumnIndex(StringToJstring('TRANSCRIPTION')); // TYPEX:=cursor.getColumnIndex(StringToJstring('TYPE')); while (cursor.moveToNext) do begin // CACHED_FORMATTED_NUMBERx:=JStringToString(cursor.getString(CACHED_FORMATTED_NUMBER)); // CACHED_LOOKUP_URIx:=JStringToString(cursor.getString(CACHED_LOOKUP_URI)); // CACHED_MATCHED_NUMBERx:=JStringToString(cursor.getString(CACHED_MATCHED_NUMBER)); CACHED_NAMEx:=JStringToString(cursor.getString(CACHED_NAME)); // CACHED_NORMALIZED_NUMBERx:=JStringToString(cursor.getString(CACHED_NORMALIZED_NUMBER)); // CACHED_NUMBER_LABELx:=JStringToString(cursor.getString(CACHED_NUMBER_LABEL)); // CACHED_NUMBER_TYPEx:=JStringToString(cursor.getString(CACHED_NUMBER_TYPE)); // CACHED_PHOTO_IDx:=JStringToString(cursor.getString(CACHED_PHOTO_ID)); // CONTENT_ITEM_TYPEx:=JStringToString(cursor.getString(CONTENT_ITEM_TYPE)); // CONTENT_TYPEx:=JStringToString(cursor.getString(CONTENT_TYPE)); // COUNTRY_ISOx:=JStringToString(cursor.getString(COUNTRY_ISO)); // DATA_USAGEx:=JStringToString(cursor.getString(DATA_USAGE)); DATEx:=JStringToString(cursor.getString(DATE)); // DEFAULT_SORT_ORDERx:=JStringToString(cursor.getString(DEFAULT_SORT_ORDER)); DURATIONx:=JStringToString(cursor.getString(DURATION)); // EXTRA_CALL_TYPE_FILTERx:=JStringToString(cursor.getString(EXTRA_CALL_TYPE_FILTER)); // FEATURESx:=JStringToString(cursor.getString(FEATURES)); // IS_READx:=JStringToString(cursor.getString(IS_READ)); // LIMIT_PARAM_KEYx:=JStringToString(cursor.getString(LIMIT_PARAM_KEY)); // NEWx:=JStringToString(cursor.getString(NEW)); // NUMBERx:=JStringToString(cursor.getString(NUMBER)); // NUMBER_PRESENTATIONx:=JStringToString(cursor.getString(NUMBER_PRESENTATION)); // OFFSET_PARAM_KEYx:=JStringToString(cursor.getString(OFFSET_PARAM_KEY)); // PHONE_ACCOUNT_COMPONENT_NAMEx:=JStringToString(cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME)); // PHONE_ACCOUNT_IDx:=JStringToString(cursor.getString(PHONE_ACCOUNT_ID)); // NUMBER_PRESENTATIONx:=JStringToString(cursor.getString(NUMBER_PRESENTATION)); // TRANSCRIPTIONx:=JStringToString(cursor.getString(TRANSCRIPTION)); // TYPEXx:=JStringToString(cursor.getString(TYPEX)); CallTime := StrToDateTime(DATEx); <- THIS DON'T WORK! Result := CACHED_NAMEx + ' ' + FormatDateTime('dd.mm.yyyy hh:mm:ss', CallTime) + ' ' + DURATIONx; ShowMessage(Result); end;
- 1
-
Android 9. And in manifest is permissions.
-
I'am having same trouble, sometimes CallStateChange works, sometimes not. I haven't figured out why.
Maybe if make Android Service, it works better. haven't tried it yet.
-
Is there way to access Android/iOS call history? In Android is permission to READ_CALL_LOG so it might be possible. Need to get calls phone number, is it incoming/outgoing and how long they lasted.
-
I been struggling with this too. What i have learned is that in Android you need to have permission to READ_CALL_LOG to get phone number. But i still have trouble get CallStateChange to trigger.
With this solution i managed to get CallStateChange trigger, but it doesn't work always. Need to try making it Android Service and see if it works better:stackoverflow.com/questions/61215767/delphi-android-read-phone-state-not-triggering
This is my code to get all three permissions:
constructor TForm1.Create(AOwner: TComponent); const PermissionAccessReadPhoneState = 'android.permission.READ_PHONE_STATE'; PermissionAccessMakeCall = 'android.permission.CALL_PHONE'; PermissionAccessReadCallLog = 'android.permission.READ_CALL_LOG'; begin inherited Create(AOwner); PermissionsService.RequestPermissions([PermissionAccessMakeCall, PermissionAccessReadPhoneState, PermissionAccessReadCallLog], procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TpermissionStatus>) begin TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)); if (Length(AgrantResults) = 3) and (AgrantResults[0] = TPermissionStatus.Granted) and (AgrantResults[1] = TPermissionStatus.Granted) and (AgrantResults[2] = TPermissionStatus.Granted) then begin ShowMessage('READ_PHONE_STATE + CALL_PHONE + READ_CALL_LOG Activated!'); end; end); if Assigned(PhoneDialerService) then begin PhoneDialerService.OnCallStateChanged := MyOnCallStateChanged; end; end;
-
Seems to be that Apple has prevent showing phone number.
In Android you need to request permission at run time to get phone state. Managed to do that, but CallStateChange still not executing. Tested on two Android phones.
-
Tested from Delphi Cookbook book phone dialing app. Works fine but instead of showing phone number at CallStateChanged, app shows some code like "9F62223E-Ao036-466E-A3EF-407105719798".
In books picture of running app phone number shows ok. This is code to show CallStateChanged:
procedure TMainForm.CallStateChanged(const ACallID: string;
const AState: TCallState);
begin
lblCall.Items.Add(Format('%-16s %s', [ACallID, CallStateAsString(AState)]));
end;I'am using iPhone, in book is pic of Android phone.
Edit: Tested with Android. Seems like in Android no CallStateChange is detected at all.
-
Thanks, found it.
Didn't thought at all that i'am looking it from wrong computer:)
- 1
-
Where can i find compiled macOs app?
I can launch app from Delphi in mac, but can't find compiled dng file from OSX64/Debug directory like windows .exe file
-
Thanks, that helped.
-
Ok, thanks. This leads to second question:
Is there easy way to check if iPhone is connected to internet?
-
Is there way to read mobile network signal strength in iOS?
-
Yes, now it's working. Thank you!
-
Hi,
Android TLocation.LocationChanged crashes when executing code at line where variable lstDistance is calculated. iOS works fine. I have tried Double type instead of Extended type but with no help. In iOS both types work fine. If i change lstDistance := 1;, code works fine.
Code is working Taximeter where charge is counted based on distance and time:)
procedure TfrmMain.senLocationLocationChanged(Sender: TObject; const OldLocation,
NewLocation: TLocationCoord2D);
var
Latitude1: Extended;
Longitude1: Extended;
Latitude2: Extended;
Longitude2: Extended;
lstDistance: Extended;
begin//MATKAN MITTAUS
Latitude1 := OldLocation.Latitude;
Longitude1 := OldLocation.Longitude;
Latitude2 := NewLocation.Latitude;
Longitude2 := NewLocation.Longitude;
lstDistance := ArcCos(Sin(DegToRad(Latitude1)) * Sin(DegToRad(Latitude2)) + Cos(DegToRad(Latitude1)) * Cos(DegToRad(Latitude2)) * Cos(DegToRad(Longitude2 - Longitude1))) * 6367000;// THESE LINES I HAVE COMMENTED OUT TO MAKE SURE THEY DON*T CAUSE CRASHING
// lstDistance := lstDistance * 1.01; //Calibrointi
// totDistance := totDistance + lstDistance;
//
// //COUNT OF MEASUREMENTS
// mitattuKpl := mitattuKpl + 1;
//
// //DISTANCE IN EUROS
// matkaE := totDistance * (0.99 / 1000);
//// TIME IN EUROS
// aikaLopetus := Now;
// kyydinKesto := aikaLopetus - aikaAloitus;
// aikaE := ((24*60)*0.89)*kyydinKesto;
// summaE := lahtoE + matkaE + aikaE;
//
// //UPDATE LABELS
// lblLongitude.Text := Format('%2.6f', [NewLocation.Longitude]);
// lblLatitude.Text := Format('%2.6f', [NewLocation.Latitude]);
// lblMitattu.Text := Format('%2.2f', [lstDistance]);
// lblMatka.Text := Format('%2.2f', [totDistance]);
// lblMittauksia.Text := IntToStr(mitattuKpl);
// lblLahto.Text := Format('%2.2f', [lahtoE]);
// lblKmE.Text := Format('%2.2f', [matkaE]);
// lblAikaE.Text := Format('%2.2f', [aikaE]);
// lblSumma.Text := Format('%2.2f', [summaE]);end;
-
Is there way to prevent iOS automatically lock screen?
I'am my self using one fitness app and it stays visible when doing workout, so it should be possible.
Object Inspector text color
in Delphi IDE and APIs
Posted
Any idea where i can change Object Inspector text color "Lila"(?) to something else. Can't see it at this age 🙂