On showing dialog I get “Can not perform this action after onSaveInstanceState”

This is common issue. We solved this issue by overriding show() and handling exception in DialogFragment extended class public class CustomDialogFragment extends DialogFragment { @Override public void show(FragmentManager manager, String tag) { try { FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.commit(); } catch (IllegalStateException e) { Log.d(“ABSDIALOGFRAG”, “Exception”, e); } } } Note that applying … Read more

Handling back button in Android Navigation Component

Newest Update – April 25th, 2019 New release androidx.activity ver. 1.0.0-alpha07 brings some changes More explanations in android official guide: Provide custom back navigation Example: public class MyFragment extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This callback will only be called when MyFragment is at least Started. OnBackPressedCallback callback = … Read more

Receive result from DialogFragment

Use myDialogFragment.setTargetFragment(this, MY_REQUEST_CODE) from the place where you show the dialog, and then when your dialog is finished, from it you can call getTargetFragment().onActivityResult(getTargetRequestCode(), …), and implement onActivityResult() in the containing fragment. It seems like an abuse of onActivityResult(), especially as it doesn’t involve activities at all. But I’ve seen it recommended by official google … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)