Skip to content

Instantly share code, notes, and snippets.

@cribetti
Last active November 18, 2020 19:51
Show Gist options
  • Save cribetti/87d1b0a09a33dabb39cc699563024d67 to your computer and use it in GitHub Desktop.
Save cribetti/87d1b0a09a33dabb39cc699563024d67 to your computer and use it in GitHub Desktop.
@NonNull
public static Fragment instantiate(@NonNull Context context, @NonNull String fname, @Nullable Bundle args) {
try {
...
Fragment f = clazz.getConstructor().newInstance();
if (args != null) {
args.setClassLoader(...);
f.setArguments(args);
}
return f;
} catch (java.lang.InstantiationException e) {
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment