Weanich Sanchol
Weanich Sanchol

Reputation: 164

Xamarin Forms : Android App can run in debug mode but crashed in release mode when changing language

I work on android app in xamarin cross platform. I have problem when the application run in release mode with datepicker. If I have datepicker in view ,I can run application normally in debug mode. If I build release .apk file and install to device, the application will crash in case of setting language&input on device as Thai language (the other language e.g. English,France can run normally). I'm not sure the problem is about the B.E. format or not and how can I fix this problem thank you.

Upvotes: 1

Views: 632

Answers (1)

fandro
fandro

Reputation: 4903

I think the problem is that when you change the language in the device, the system Date Format does not correspond to the DateTime Format.

Try to set it in code when changing the language :

In xaml :

   <DatePicker x:Name="MyDatePicker" VerticalOptions="CenterAndExpand" 
                 Date="{x:Static sys:DateTime.Now}">
       </DatePicker> 

In C# :

 MyDatePicker.Format = "yyyy-MM-dd"; 
 MyDatePicker.Date = new DateTime(); // Set the date time as you want it. And remove the Date attribute in the Xml

Hope it helps

Upvotes: 1

Related Questions