0

Can you help me. I have a code, but it don't work on Android (who would doubt that).

procedure SetTime(sTime: string);

var
   vsys: _SYSTEMTIME;

begin
  GetLocalTime(vsys);
  vsys.wYear := StrToInt(Copy(sTime,7,4));
  vsys.wMonth := StrToInt(Copy(sTime,4,2));
  vsys.wDay := StrToInt(Copy(sTime,1,2));
  vsys.wHour := StrToInt(Copy(sTime,12,2));
  vsys.wMinute := StrToInt(Copy(sTime,15,2));
  vsys.wSecond := StrToInt(Copy(sTime,18,2));
  SetLocalTime(vsys);
end;

I need a similar code, but to make it work on Android or analogy. Thanks in advance

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 1
    Try some websearch. You are attempting to change the time on the device. Have you searched for that. – David Heffernan Oct 29 '15 at 11:46
  • I found the information, but it either does not fit me, or was not it. I do not sit and wait until the answer. At the same time I'm looking for this information, and chat forums. But I would be glad if someone answered my specific case – user5502660 Oct 29 '15 at 12:05

1 Answers1

0

User applications do not have permission to change the date/time on the device. This is discussed in much more detail here: How to set mobile system time and date in android?

Perhaps the best you can do then is to invoke the system date/time settings activity. In Java code that would be

startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));

This should be simple enough for you to translate to the Delphi equivalent. This Embarcadero code example covers how to do that: http://docwiki.embarcadero.com/CodeExamples/Seattle/en/FMX.Android_Intents_Sample

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Oh. It is so terrible! I need to synchronized the server with my application. This is necessary not to be out of sync. I'll have to do it later. But thank you – user5502660 Oct 29 '15 at 12:32