SagarAnjWebTech
SagarAnjWebTech

Reputation: 27

TimeZoneInfo.GetSystemTimeZones().Count gives 0 for unity android app

TimeZoneInfo.GetSystemTimeZones().Count gives 0 for unity android app, is there any permission required from android side to get TimeZone data?

Debug.LogError("GetSystemTimeZones... " + System.TimeZoneInfo.GetSystemTimeZones().Count);

Output : GetSystemTimeZones... 0

Upvotes: 1

Views: 1155

Answers (2)

saeed foroughi
saeed foroughi

Reputation: 1708

based on the documentation it is supposed to return 0 in android! but I saw some people do a workaround to solve this problem. it goes as follow: you can create a jar with Android Studio and get the timezones you need there and then create a C# script to access that jar file. here you can find a toturial on how to do it.

although in this scenario there is a drawback, you can only pass Strings with this solution.

Upvotes: 1

Andrea
Andrea

Reputation: 6123

I think this method always returns 0 on Android. Reading on the Documentation for TimeZoneInfo:

The GetSystemTimeZones method retrieves all available time zone information from the subkeys of the registry's HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zones key on Windows systems and from the ICU Library on Linux and macOS.

As you can see, Android is not mentioned.

Upvotes: 1

Related Questions