【问题标题】:java - How to fix The method setLatestEventInfo(AlarmService_Service, String, CharSequences, PendingIntent) is undefined for the type Notificationjava - 如何修复通知类型未定义方法 setLatestEventInfo(AlarmService_Service, String, CharSequences, PendingIntent)
【发布时间】:2017-04-15 21:36:03
【问题描述】:

如何修复通知类型未定义方法 setLatestEventInfo(AlarmService_Service, String, CharSequences, PendingIntent)

请帮忙解决这个错误

这是脚本:

/**
 * Show a notification while this service is running.
 */
private void showNotification() {
    // In this sample, we'll use the same text for the ticker and the expanded notification
  CharSequence text = "Doctor Jokes SF";

    // Set the icon, scrolling text and timestamp
  Notification notification = new Notification(R.drawable.icon, text,System.currentTimeMillis());

  Intent notifyIntent = new Intent(this, MainActivity.class);
 // Sets the Activity to start in a new, empty task
 notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

    // The PendingIntent to launch our activity if the user selects this notification
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
      notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    // Set the info for the views that show in the notification panel.
    notification.setLatestEventInfo(this, quote.getBody(), text, contentIntent);

    notification.flags |=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
  //Define sound URI
    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    notification.sound = soundUri;

    // Send the notification.
    // We use a layout id because it is a unique number.  We use it later to cancel.
    mNM.cancelAll();
    mNM.notify(0, notification);
}

【问题讨论】:

  • javascript java 还是 c# ?它是什么? 100% 不是 javascript
  • 此脚本取自游戏代码源中名为 AlarmService_Service.java 的文件,所以这是 javascript!
  • 不,不是,javascript 是与 java 不同的语言。
  • 是的,先生,你是对的,但如果你知道如何解决这个问题,请告诉我如何

标签: javascript java c# android eclipse


【解决方案1】:

显然它已被弃用,您应该使用通知生成器。查看this answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多