@@ -36,26 +36,57 @@ private LanguageUtils() {
3636 /**
3737 * Apply the system language.
3838 *
39- * @param mainActivityClz The class of activity will be started after apply system language.
39+ * @param activityClz The class of activity will be started after apply system language.
4040 */
41- public static void applySystemLanguage (final Class <? extends Activity > mainActivityClz ) {
42- applyLanguage (Resources .getSystem ().getConfiguration ().locale , mainActivityClz , true );
41+ public static void applySystemLanguage (final Class <? extends Activity > activityClz ) {
42+ applyLanguage (Resources .getSystem ().getConfiguration ().locale , activityClz , true );
43+ }
44+
45+ /**
46+ * Apply the system language.
47+ *
48+ * @param activityClassName The full class name of activity will be started after apply system language.
49+ */
50+ public static void applySystemLanguage (final String activityClassName ) {
51+ applyLanguage (Resources .getSystem ().getConfiguration ().locale , activityClassName , true );
4352 }
4453
4554 /**
4655 * Apply the language.
4756 *
48- * @param locale The language of locale.
49- * @param mainActivityClz The class of activity will be started after apply system language.
50- * It will start the launcher activity if the class is null.
57+ * @param locale The language of locale.
58+ * @param activityClz The class of activity will be started after apply system language.
59+ * It will start the launcher activity if the class is null.
5160 */
5261 public static void applyLanguage (@ NonNull final Locale locale ,
53- final Class <? extends Activity > mainActivityClz ) {
54- applyLanguage (locale , mainActivityClz , false );
62+ final Class <? extends Activity > activityClz ) {
63+ applyLanguage (locale , activityClz , false );
64+ }
65+
66+ /**
67+ * Apply the language.
68+ *
69+ * @param locale The language of locale.
70+ * @param activityClassName The class of activity will be started after apply system language.
71+ * It will start the launcher activity if the class name is null.
72+ */
73+ public static void applyLanguage (@ NonNull final Locale locale ,
74+ final String activityClassName ) {
75+ applyLanguage (locale , activityClassName , false );
76+ }
77+
78+ private static void applyLanguage (@ NonNull final Locale locale ,
79+ final Class <? extends Activity > activityClz ,
80+ final boolean isFollowSystem ) {
81+ if (activityClz == null ) {
82+ applyLanguage (locale , "" , isFollowSystem );
83+ return ;
84+ }
85+ applyLanguage (locale , activityClz .getName (), isFollowSystem );
5586 }
5687
5788 private static void applyLanguage (@ NonNull final Locale locale ,
58- final Class <? extends Activity > mainActivityClz ,
89+ final String activityClassName ,
5990 final boolean isFollowSystem ) {
6091 if (isFollowSystem ) {
6192 SPUtils .getInstance ().put (KEY_LOCALE , "" );
@@ -67,13 +98,10 @@ private static void applyLanguage(@NonNull final Locale locale,
6798
6899 updateLanguage (Utils .getApp (), locale );
69100
70- Intent intent ;
71- if (mainActivityClz == null ) {
72- intent = new Intent ();
73- intent .setComponent (new ComponentName (Utils .getApp (), getLauncherActivity ()));
74- } else {
75- intent = new Intent (Utils .getApp (), mainActivityClz );
76- }
101+ Intent intent = new Intent ();
102+ String realActivityClassName
103+ = TextUtils .isEmpty (activityClassName ) ? getLauncherActivity () : activityClassName ;
104+ intent .setComponent (new ComponentName (Utils .getApp (), realActivityClassName ));
77105 intent .addFlags (
78106 Intent .FLAG_ACTIVITY_NEW_TASK
79107 | Intent .FLAG_ACTIVITY_CLEAR_TOP | Intent .FLAG_ACTIVITY_CLEAR_TASK
0 commit comments