1010
1111import android .app .Activity ;
1212import android .content .Context ;
13+ import android .content .Intent ;
1314import android .util .Log ;
1415import android .content .ComponentName ;
1516import android .content .pm .PackageManager ;
1617
1718public class AppIconBase {
1819
1920 private Activity activity ;
21+ private Context context ;
2022 private List <String > disableIconNames = new ArrayList <String >();
2123 private String activeIconName = "" ;
2224 private String packageName ;
@@ -25,6 +27,8 @@ public class AppIconBase {
2527
2628 public AppIconBase (Activity activity , Context context ) {
2729 this .activity = activity ;
30+ this .context = context ;
31+
2832 this .packageName = context .getPackageName ();
2933 pm = context .getApplicationContext ().getPackageManager ();
3034 activeIconName = "" ;
@@ -35,9 +39,11 @@ public Boolean isSupported() {
3539 }
3640
3741 public String getName () {
38- ComponentName componentName = new ComponentName (this .activity , this .activity .getClass ());
42+ Intent intent = pm .getLaunchIntentForPackage (context .getPackageName ());
43+ ComponentName componentName = intent .getComponent ();
3944 int status = pm .getComponentEnabledSetting (componentName );
40- if (status == PackageManager .COMPONENT_ENABLED_STATE_ENABLED ) {
45+
46+ if (status == PackageManager .COMPONENT_ENABLED_STATE_ENABLED || status == PackageManager .COMPONENT_ENABLED_STATE_DEFAULT ) {
4147 // The component is currently enabled
4248 String name = componentName .getShortClassName ();
4349 if (Objects .equals (name , ".MainActivity" )) {
0 commit comments