-1

im developing xamarin.android app.I need to get title name of the application from package name.

ex :

  • package name- com.google.android.gm
  • title name - Gmail

tried this code. this give me unhanded exception

 string appName = pm.GetApplicationLabel(pm.GetApplicationInfo("com.google.android.gm", PackageInfoFlags.MetaData));

exception -

Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object.

03-14 10:54:58.122 I/zygote64(15547): Thread[3,tid=15553,WaitingInMainSignalCatcherLoop,Thread*=0x73480c0400,peer=0x1ca00020,"Signal Catcher"]: reacting to signal 3
03-14 10:54:58.123 I/zygote64(15547): 
03-14 10:54:58.258 I/zygote64(15547): Wrote stack traces to '/data/anr/traces.txt'

1 Answers1

1

Finally found the reason. here is the complete code.

string appName = PackageManager.GetApplicationLabel(PackageManager.GetApplicationInfo("com.google.android.gm", PackageInfoFlags.MetaData));

this returns "Gmail"