Skip to content

Commit

Permalink
Merge pull request #44 from aeharding/fix-getname
Browse files Browse the repository at this point in the history
Fix getName() on Android
  • Loading branch information
johnborges authored Oct 8, 2023
2 parents 1ba8a9b + c3dbd20 commit ee03f9b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.content.ComponentName;
import android.content.pm.PackageManager;

public class AppIconBase {

private Activity activity;
private Context context;
private List<String> disableIconNames = new ArrayList<String>();
private String activeIconName = "";
private String packageName;
Expand All @@ -25,6 +27,8 @@ public class AppIconBase {

public AppIconBase(Activity activity, Context context) {
this.activity = activity;
this.context = context;

this.packageName = context.getPackageName();
pm = context.getApplicationContext().getPackageManager();
activeIconName = "";
Expand All @@ -35,9 +39,11 @@ public Boolean isSupported() {
}

public String getName() {
ComponentName componentName = new ComponentName(this.activity, this.activity.getClass());
Intent intent = pm.getLaunchIntentForPackage(context.getPackageName());
ComponentName componentName = intent.getComponent();
int status = pm.getComponentEnabledSetting(componentName);
if (status == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {

if (status == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || status == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
// The component is currently enabled
String name = componentName.getShortClassName();
if (Objects.equals(name, ".MainActivity")) {
Expand Down

0 comments on commit ee03f9b

Please sign in to comment.