DialogFragment is called from the fragment (settings) by clicking on a TextView, in which I change the settings (language) of the application, how do I, after closing DialogFragment, apply settings without reloading the entire application? and ideally, the languages should be changed immediately in the SingleChoice selection dialog. With reboot everything works. Here is the DialogFragment code:
public class LanguageDialogFragment extends DialogFragment { final String[] itemsLang = {"English", "Russian", "Ukraine"}; final String[] items = {"en", "ru", "uk"}; String lang; MainActivity activity = new MainActivity(); @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Выберите свой родной язык") .setSingleChoiceItems(itemsLang, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { lang = items[item]; } }) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { App.prefs.saveLanguage(lang); App.changeLang(lang); reload(); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); } private void reload() { Intent intent = getActivity().getIntent(); getActivity().finish(); Intent LaunchIntent = getActivity().getPackageManager().getLaunchIntentForPackage(App.context.getPackageName()); startActivity(LaunchIntent); } } Below is an example of the application I would like to implement: https://play.google.com/store/apps/details?id=com.funeasylearn.english Screenshots from it:
