Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25756] Android: Restart app on system locale change

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-11-09T21:06:26.000+0000
Affected Version/sRelease 7.1.0
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid, android:configChanges, locale
ReporterJorge Macias Garcia
AssigneeGary Mathews
Created2017-12-19T11:53:17.000+0000
Updated2018-11-15T07:31:08.000+0000

Description

Apps in Titanium doesn't restart the activities when locale config has changed and the broadcast event is fired. From the documentation: https://developer.android.com/guide/topics/manifest/activity-element.html#config "Locale" The locale has changed; the user selected a new text language. As you can see in the documentation page. If android:configChanges are added to the manifest in an activity block is the app who should handle this changes. If not, the app is restarted by default (as expected). I found this broadcast handler in the titanium source code but the behaviour isn't as expected. Adding 'locale' to android:configChange doesn't works. Generated and modified manifest (adding locale to android:configChanges):
		<activity android:name=".AppTestActivity" android:label="@string/app_name" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation|fontScale|screenSize|smallestScreenSize|screenLayout|density|locale">
			<intent-filter>
				<action android:name="android.intent.action.MAIN"/>
				<category android:name="android.intent.category.LAUNCHER"/>
			</intent-filter>
		</activity>
I've tried removing android:configChanges attribute in my custom manifest to get the default behaviour but it is added again. By default the generated manifest by Titanium has the android:configChanges flag enabled with custom properties. It's Titanium who handles this changes. TEST APP: Languages: en, es Expected behaviour: Settings > Languages > Change language > Come back to app > Activity has been restarted with new language Current behaviour: Settings > Languages > Change language > Come back to app > Activity hasn't been restarted with new language

Attachments

FileDateSize
android-lang-behaviour.gif2018-01-02T09:57:13.000+00001030671
android-restart-app-when-language-changed.gif2018-02-05T07:29:29.000+00001817156
app.zip2018-01-02T09:57:49.000+00007124503
locale_8.1.gif2018-11-09T21:03:44.000+0000552702

Comments

  1. Sharif AbuDarda 2017-12-27

    Hello, Please provide a full reproducible code for us to test. Thanks.
  2. Mostafizur Rahman 2018-01-02

    Hello [~jormagar], Are you able to sorted this out? If not ,please provide a sample test code to reproduce the issue on our end? Best
  3. Jorge Macias Garcia 2018-01-02

    @Mostafizur Rahman, @Sharif AbuDarna, sorry for the delay. Just updated the ticket.
  4. Sharif AbuDarda 2018-02-04

    Hello, With the sample code you provided I wasn't able to reproduce the issue with Android 8.0.0. In SDK 7.0.1.GA. With language change, activity has been restarted with new language. Thanks.
  5. Jorge Macias Garcia 2018-02-05

    !android-restart-app-when-language-changed.gif! I recompiled the test app with latest sdk 7.0.1 with Android 8 sim and it's not working. As you can see in the attached gif, you need to kill the app and open it again to get working the changed language. On iOS platform it is done on the air and not need to kill / restart the app to see the new language. The right behaviour on Android would be: - Open app and leave the app on background - Go to settings and change language - Come back to your running app from recent tasks. - App should be restarted by system.
  6. Gary Mathews 2018-03-15

    master: https://github.com/appcelerator/titanium_mobile/pull/9937
  7. Christopher Williams 2018-05-14

    I think given that the PR is still marked a work in progress that this won't make the cut for 7.2.0. Bumping to 7.3.0 for now.
  8. Lokesh Choudhary 2018-09-27

    FR Passed.
  9. Lokesh Choudhary 2018-10-15

    PR Merged.
  10. Keerthi Mahalingam 2018-10-16

    Verified the fix on SDK 7.5.0.v20181015122219 .Works fine. Closing
     
        Operating System
          Name                        = Mac OS X
          Version                     = 10.13.6
          Architecture                = 64bit
        Node.js
          Node.js Version             = 8.9.1
          npm Version                 = 5.5.1
        Titanium CLI
          CLI Version                 = 5.1.1
        Titanium SDK
          SDK Version                 =7.5.0.v20181015122219
        Device			      =Pixel 2 xl android 8 emulator
        
  11. Jorge Macias Garcia 2018-11-09

    It doesn't works fine... test app crashes on Android 8.1 simulator. Steps: 1. Open test app and send it to background pressing on home button. 2. Open language settings and set spanish to main language 3. Open recent apps and select test app, it is restarted as expected. It could work or not. See attached new GIF
  12. Jorge Macias Garcia 2018-11-09

    [Locale changed not solved](http://personales.upv.es/jormagar/gif/locale_changed_still_fail.gif)
  13. Lokesh Choudhary 2018-11-09

    [~jormagar], App will soft restart only when there is no locale change event listener. This is by design. I tried but not able to repro the crash. !locale_8.1.gif!
  14. Lokesh Choudhary 2018-11-09

    Had reopened to add a gif.
  15. Jorge Macias Garcia 2018-11-10

    You are not trying what I'm reporting. Follow the steps to get the crash please.
  16. Yordan Banev 2018-11-12

    [~lchoudhary] Can you check what the value of run-on-main-thread in tiapp.xml is in the application you ran? I was able to reproduce the crash with it when the property is set to false.
  17. Lokesh Choudhary 2018-11-13

    [~ybanev], I have it set to true
        <property name="run-on-main-thread" type="bool">true</property>
        
  18. Jorge Macias Garcia 2018-11-15

    @lchoudhary set it to false and see what happens with the app testing again the use case. You will check how it crashes.

JSON Source