Android LED_NOTIFICATION_ID 无法解析为变量

发布于 2024-12-22 01:58:16 字数 634 浏览 2 评论 0原文

我查找了有关如何让 Android 设备 LED 闪烁的示例,并且收到了有关无法将 LED_NOTIFICATION_ID 解析为变量的消息。我的代码如下。有谁可以告诉我为什么会收到此错误?

private void redFlashLight(Context context)
    {
        NotificationManager nm = ( NotificationManager ) context.getSystemService( context.NOTIFICATION_SERVICE );
        Notification notif = new Notification();
        notif.ledARGB = 0xFFff0000;
        notif.flags = Notification.FLAG_SHOW_LIGHTS;
        notif.ledOnMS = 100; 
        notif.ledOffMS = 100; 
        notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE;
        nm.notify(LED_NOTIFICATION_ID, notif);
    }

I've looked for examples on how to get the android device LED to blink and I've gotten the message about not being able to resolve LED_NOTIFICATION_ID to a variable. My code is below. Is there anyone that can tell me why I'm receiving this error?

private void redFlashLight(Context context)
    {
        NotificationManager nm = ( NotificationManager ) context.getSystemService( context.NOTIFICATION_SERVICE );
        Notification notif = new Notification();
        notif.ledARGB = 0xFFff0000;
        notif.flags = Notification.FLAG_SHOW_LIGHTS;
        notif.ledOnMS = 100; 
        notif.ledOffMS = 100; 
        notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE;
        nm.notify(LED_NOTIFICATION_ID, notif);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘寄 2024-12-29 01:58:16

那时您还没有将 LED_NOTIFICATION_ID 声明为变量。查找拼写错误。它应该用类名来限定吗?

You haven't declared LED_NOTIFICATION_ID as a variable then. Look for misspellings. Is it supposed to be qualified with a class name?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文