如何在 Xamarin 的本地通知中显示应用程序名称?

Max*_*ime 5 c# notifications xamarin.android xamarin xamarin.forms

我有一个带有本地通知的应用程序。问题是它显示了来自 Visual Studio 的“项目名称”(见截图)。我希望应用程序显示我可以指定的内容(应用程序名称)。

[2]

构建您在上面看到的通知的代码是:

PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

// Build the notification:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .SetAutoCancel(true)
    .SetContentIntent(resultPendingIntent)
    .SetContentTitle("Button Clicked")
    .SetNumber(count)
    .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
    .SetContentText(String.Format("The button has been clicked {0} times.", count));

// Finally, publish the notification:
NotificationManager notificationManager = (NotificationManager)GetSystemServiceContext.NotificationService);
notificationManager.Notify(ButtonClickNotificationId, builder.Build());
Run Code Online (Sandbox Code Playgroud)

我正在使用 Android 7.0 进行测试,似乎本地通知文档没有显示有关这种“新”显示通知方式的任何信息。不过,我可以更改小图标。

我在 Xamarin 论坛或 Google 上找不到有关该问题的任何信息。我真的怀疑人们想在那里看到 Visual Studio 的项目名称。

我什至下载了本地通知示例项目,它显示了项目名称。

这是限制还是我错过了什么?在我看来,它太重要而不能成为限制。

Sus*_*ver 5

您正在寻找Android应用程序的android:labelAndroidManifest.xml,被誉为Xamarin.Android项目设置中的“应用程序名称”。

在此处输入图片说明

AndroidManifest.xml

~~~~
<application android:label="StackoverFlow" ~~~
~~~~
Run Code Online (Sandbox Code Playgroud)

输出:

在此处输入图片说明

注意:AndroidManifest.xml您也可以使用程序集级别,而不是直接在 中进行设置ApplicationAttribute

[assembly: Application(Icon = "@drawable/Icon", Label = "StackOverflow")]
Run Code Online (Sandbox Code Playgroud)

仅供参考:Xamarin 的项目模板AssemblyInfo.cs使用 Icon 参数创建此 Application 属性