我正在开发xamarin.android app.I需要从包名中获取应用程序的标题名称。
前:
尝试了这段代码。这给了我无耻的例外
string appName = pm.GetApplicationLabel(pm.GetApplicationInfo("com.google.android.gm", PackageInfoFlags.MetaData));
例外 -
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'
答案 0 :(得分:0)
string appName = PackageManager.GetApplicationLabel(PackageManager.GetApplicationInfo("com.google.android.gm", PackageInfoFlags.MetaData));
这会返回“Gmail”