Class Shell.Initializer

java.lang.Object
com.topjohnwu.superuser.Shell.Initializer
Enclosing class:
Shell

public static class Shell.Initializer extends Object
The initializer when a new Shell is constructed.

This is an advanced feature. If you need to run specific operations when a new Shell is constructed, extend this class, add your own implementation, and register it with Shell.Builder.setInitializers(Class[]). The concept is similar to .bashrc: run specific scripts/commands when the shell starts up. onInit(Context, Shell) will be called as soon as the shell is constructed and tested as a valid shell.

An initializer will be constructed and the callbacks will be invoked each time a new shell is created.

  • Constructor Details

    • Initializer

      public Initializer()
  • Method Details

    • onInit

      public boolean onInit(@NonNull Context context, @NonNull Shell shell)
      Called when a new shell is constructed.
      Parameters:
      context - the application context.
      shell - the newly constructed shell.
      Returns:
      false when initialization fails, otherwise true.