gpt4 book ai didi

c# - 当我在 Android 中通知时,如何让我的通知下拉?

转载 作者:太空宇宙 更新时间:2023-11-03 23:25:16 24 4
gpt4 key购买 nike

当我在 Android 中显示通知时,通知会放置在 Android 的通知区域中。当我下拉时我可以看到它,但它不会像我看到的许多应用程序那样自动下拉。如何强制通知下拉?我的应用程序打开时这可能吗?它是否仅在我的应用程序关闭或未全屏时才会下拉?

我正在使用 Xamarin,这是我的代码(基本上是从 Google 自己的示例中复制的):

更新 代码 fragment 现在可以工作并显示“提醒”通知。

string title = activity.Resources.GetString(Resource.String.Label_VideoSaved);
string text = string.Format(activity.Resources.GetString(Resource.String.Text_FileLocation), OutputFile);
Notification.Builder b = new Notification.Builder(activity);
b.SetSmallIcon(Resource.Drawable.Icon);
b.SetContentTitle(title);
b.SetContentText(text);
b.Extras.PutString("video", OutputFile);

// create a "heads up" notification with the following 2 lines:
b.SetPriority((int)Android.App.NotificationPriority.High);
b.SetVibrate(new long[0]);

Intent resultIntent = new Intent(activity, typeof(ViewVideoActivity));
TaskStackBuilder stackBuilder = TaskStackBuilder.Create(activity);
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(ViewVideoActivity)));
stackBuilder.AddNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent);
b.SetContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager)activity.GetSystemService(Context.NotificationService);
notificationManager.Notify(0, b.Build());

最佳答案

我想你想要的是一个“提醒”通知: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Heads-up

Examples of conditions that may trigger heads-up notifications include:

The user's activity is in fullscreen mode (the app uses fullScreenIntent),

The notification has high priority and uses ringtones or vibrations

关于c# - 当我在 Android 中通知时,如何让我的通知下拉?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34009621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com