【问题标题】:Xamarin Android Local NotificationXamarin Android 本地通知
【发布时间】:2015-12-11 18:18:49
【问题描述】:

我在项目中使用 API 级别 10(Xamarin.Android v2.3 支持)

程序集引用丢失错误。

在主要活动中

按钮点击处理程序有以下代码

        Bundle valuesForActivity = new Bundle();
        valuesForActivity.PutInt("count", _count);

        // Create the PendingIntent with the back stack
        // When the user clicks the notification, SecondActivity will start up.
        Intent resultIntent = new Intent(this, typeof(SecondActivity));
        resultIntent.PutExtras(valuesForActivity); // Pass some values to SecondActivity.

        TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
        stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(SecondActivity)));
        stackBuilder.AddNextIntent(resultIntent);

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

        // Build the notification          
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .SetAutoCancel(true) // dismiss the notification from the notification area when the user clicks on it
            .SetContentIntent(resultPendingIntent) // start up this activity when the user clicks the intent.
            .SetContentTitle("Button Clicked") // Set the title
            .SetNumber(_count) // Display the count in the Content Info
            .SetSmallIcon(Resource.Drawable.monoandroidsplash) // This is the icon to display
            .SetContentText(String.Format("The button has been clicked {0} times.", _count)); // the message to display.

        // Finally publish the notification
        NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService);
        notificationManager.Notify(ButtonClickNotificationId, builder.Build());

        _count++;`

获取错误

TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this)

错误是缺少程序集引用和TaskStackBuilder 不存在

我没有得到程序集参考中缺少的内容 请帮忙

【问题讨论】:

    标签: xamarin.ios xamarin xamarin.android


    【解决方案1】:

    回复较晚,但可能对其他人有所帮助。

    您提到的问题是由于 Mono.Anroid 的版本(较低)而发生的

    在较低版本(例如 4.2)中,缺少 Android.App.TaskstackBuilder 命名空间。 升级 Mono.Android 可能会解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      相关资源
      最近更新 更多