Android Question TimeDialog & DateDialog no arabic numbers

ilan

Expert
Licensed User
Longtime User
hi

if my phone is set to Arabic and i use my app i get some crashes when i try to use the timedialog and datedialog because the Arabic numbers are written differently.

it happens after when i try to use the string that i converted from the returned long. so is it possible to use ONLY numbers as usual in timedialog or datedialog even if the phone language is set to Arabic?


thanx
 

ilan

Expert
Licensed User
Longtime User
Try to call this code in Service_Create of the starter service: https://www.b4x.com/android/forum/threads/unparseable-date.75927/#post-481825

thanx erel i have tested it but i found 1 issue using this code.

i put it in starter service in create event and then i am trying to choose the date and it is working BUT after an ad appears and i close the ad and return to the application that setting is gone and i have again arabic digits.

so i guess i will need to put this code in activity_resume and not in starter service. what do you think?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
so i guess i will need to put this code in activity_resume and not in starter service.

ok this will not work. not in activity_resume and not in activity_create.
the only way it works is putting it in starter_create event but it works until you exit and return to the app. (like showing an ad) :(
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
This is strange as the code sets the process default locale. It can only happen if the process is killed and then started without starting the starter service. If you can reproduce it in a small project then I'll test it.

thanx erel, i am including a project where i can reproduce it and also a video.

thank you for your great support.

 

Attachments

  • TimeDialogTest.zip
    4.1 KB · Views: 297
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the correct code and it should be in Activity_Create:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim ctxt, jo As JavaObject
   ctxt.InitializeContext
   jo.InitializeStatic("java.util.Locale")
   ctxt.RunMethodJO("getResources", Null).RunMethodJO("getConfiguration", Null).RunMethod("setLocale",  Array(jo.GetField("US")))
   jo.RunMethod("setDefault", Array(jo.GetField("US")))
End Sub
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
This is the correct code and it should be in Activity_Create:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim ctxt, jo As JavaObject
   ctxt.InitializeContext
   jo.InitializeStatic("java.util.Locale")
   ctxt.RunMethodJO("getResources", Null).RunMethodJO("getConfiguration", Null).RunMethod("setLocale",  Array(jo.GetField("US")))
   jo.RunMethod("setDefault", Array(jo.GetField("US")))
End Sub

sorry erel but this is not working. if you will set your device to arabic you will see that the dialog will be shown in arabic after the ad appears.
 
Upvote 0
Top