Class FozaActivityManager

java.lang.Object
lu.die.fozacompatibility.FozaActivityManager

public class FozaActivityManager extends Object
Version:
1.0
Author:
king@62v.net
See Also:
  • ActivityManager
  • Constructor Details

    • FozaActivityManager

      public FozaActivityManager()
  • Method Details

    • get

      public static FozaActivityManager get()
    • obtainSplashLaunchIntent

      public android.content.Intent obtainSplashLaunchIntent(String pkg, android.content.Context context)
      Obtain a splash screen intent
      Parameters:
      pkg - package name
      context - app context
      See Also:
    • launchApp

      public void launchApp(String pkg)
      Launch a specific package with the default user name
      Parameters:
      pkg - package name
    • launchActivityExistingAppProcess

      public void launchActivityExistingAppProcess(String pkg)
    • launchActivityExistingAppProcess

      public void launchActivityExistingAppProcess(String pkg, String username)
      Launch an app which is running directly, will success only if the app was launched (without hesitation). You must call the function isAppRunning before calling this method
      Parameters:
      pkg - package name you want to launch
      username - user name, must be alphabetical
    • initialize

      public void initialize(android.content.Context context)
      Initialize the environment
      Parameters:
      context - application base context
      See Also:
    • isInnerPackageInstalled

      public boolean isInnerPackageInstalled(String pkg)
      Detect if an app is installed or not
      Parameters:
      pkg - package name
      Returns:
      if app was installed already then true, otherwise false.
    • isAppRunning

      public boolean isAppRunning(String pkg)
    • isAppRunning

      public boolean isAppRunning(String pkg, String username)
      Detect if an app is running or not
      Parameters:
      pkg - package name
      username - user name
      Returns:
      true if the app is running
    • launchExistingApp

      public void launchExistingApp(String pkg, String username)
      Launch an existing app process, will be the same behaviour as launchActivityExistingAppProcess if the app is running If an app is already running, then move its splash screen to the display top.
      Parameters:
      pkg - package name
      username - user name
      See Also:
    • isAppRunning

      public boolean isAppRunning(String pkg, int uid)
      Detect if an app is running
      Parameters:
      pkg - package name
      uid - user name (alias of user name, use String.valueOf to convert)
      Returns:
      true if the app is running
    • killAllApps

      public void killAllApps()
      Kill all running applications
      See Also:
      • Process.killProcess(int)
    • launchApp

      public void launchApp(int uid, String pkg)
      Launch an app, mostly used function.
      Parameters:
      uid - userid, same as the String user name function.
      pkg - package name
      See Also:
    • launchApp

      public void launchApp(String username, String pkg)
      Launch an app and initialize its environment. You can launch a specific app by this method.
      Parameters:
      username - user name, you can use the String.valueOf to convert
      pkg - package name FozaActivityManager.get().launchApp("0", "com.whatsapp")
    • obtainSplashLaunchIntent

      public android.content.Intent obtainSplashLaunchIntent(int username, String pkg, android.content.Context context)
      Numeric user name method
      See Also:
    • obtainSplashLaunchIntent

      public android.content.Intent obtainSplashLaunchIntent(String username, String pkg, android.content.Context context)
      Obtain a splash screen intent
      Parameters:
      username - user name
      pkg - package name
      context - app context
      Returns:
      if null then application already launched, else you should call the startActivity function, and you must manual start the activity intent if return not null value
      See Also:
      • val splash = FozaActivityManager.get().obtainSplashLaunchIntent("0", "com.whatsapp", this) startActivity(splash)
    • factoryReset

      public void factoryReset()
      Delete all apps you've installed.
      See Also:
      • FilesKt__UtilsKt.deleteRecursively(File)
    • launchIntent

      public void launchIntent(android.content.Intent intent)
    • launchIntent

      public void launchIntent(android.content.Intent intent, int uid)
    • launchIntent

      public void launchIntent(android.content.Intent intent, String username)
      Launch a specific intent, you can launch an intent with specific extras or data here Can launch a disabled activity, and please add a NEW_TASK flag to launch
      Parameters:
      intent - intent you want to launch
      username - user name
    • killAppByPkg

      public void killAppByPkg(String pkg)
      Kill application process, with app relevant users
      Parameters:
      pkg - package name
    • broadcastIntentAsUser

      public int broadcastIntentAsUser(android.content.Intent intent, String username)
      Broadcast an intent to internal app
      Parameters:
      intent - intent you want to broadcast
      username - user name
      Returns:
      1 if success
    • broadcastIntentAsUser

      public int broadcastIntentAsUser(android.content.Intent intent, int username)
    • getPackageByPid

      public String getPackageByPid(int pid)
    • killAppByPkg

      public void killAppByPkg(String username, String pkg)
      Kill application process by package name and user name
      Parameters:
      username - user name
      pkg - package name
    • killAppByPkg

      public void killAppByPkg(int uid, String pkg)
    • setUserName

      public void setUserName(String username)
      Set a default user name, and defaults 0
      Parameters:
      username - user name
    • acquirePreloadNextProcess

      public void acquirePreloadNextProcess()
      You can call this function in your main activity. Calling this method is not necessary. This method will boost the first application launch progress.
      See Also:
      • Process.myPid()