Forum Xamarin.Android

could not load type android.content.pm.packagemanager invoker

BrunoVTBrunoVT BEUniversity ✭✭

Hi,

When I want to get the applicationname in my custom view class I somethimes get above exception for the packagemanager in the context. Any suggestions?

var name = Application.Context.PackageManager.GetApplicationLabel(Application.Context.PackageManager.GetApplicationInfo(Application.Context.ApplicationInfo.PackageName, 0));

Answers

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @BrunoVT Try something like this :

        public static string GetApplicationName(Android.Content.Context context)
        {
          int stringId = context.ApplicationInfo.LabelRes;
          return context.GetString(stringId);
        } 
    
Sign In or Register to comment.