content: package com.agnostic.apollo.taskerlaunchershortcut.utils;
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.app.role.RoleManager;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.content.pm.PackageManager;
  import android.content.pm.ResolveInfo;
  import android.os.Build;
  
  import com.agnostic.apollo.taskerlaunchershortcut.FakeLauncherHome;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import static android.content.Context.ROLE_SERVICE;
  
  public class LauncherUtils {
  
      public static void changeDefaultLauncherInitiate(Activity context) {
          if (context == null)
              return;
  
          PackageManager packageManager = context.getPackageManager();
          ComponentName componentName = new ComponentName(context.getApplicationContext(), FakeLauncherHome.class);
          packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
  
          Intent intent = new Intent(Intent.ACTION_MAIN);
          intent.addCategory(Intent.CATEGORY_HOME);
          context.startActivity(intent);
  
          packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
      }
  
      public static boolean isMyAppLauncherDefault(Context context) {
  
          if (context == null)
              return false;
  
          final Intent intent = new Intent(Intent.ACTION_MAIN);
          intent.addCategory(Intent.CATEGORY_HOME);
          final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);
          if (resolveInfo!=null && resolveInfo.activityInfo != null && context.getPackageName()
                  .equals(resolveInfo.activityInfo.packageName)) {
              return true;
          }
          return false;
      }
  
      public static void startLauncherHome(Activity context) {
          Intent intent = new Intent(Intent.ACTION_MAIN);
          intent.addCategory(Intent.CATEGORY_HOME);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY);
          context.startActivity(intent);
      }
  }
  