通过Java使用OS X 10.8通知中心(NSUserNotification) [英] Using OS X 10.8 Notification Center (NSUserNotification) with Java

查看:77
本文介绍了通过Java使用OS X 10.8通知中心(NSUserNotification)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OS X 10.8中的通知中心苦苦挣扎.我编写了一个包装程序,以通过JNA提供Java访问NSUserNotification和NSUserNotificationCenter类的功能,但是功能受到限制.我能够发送通知,并且只要通过JavaApplicationStub从.app捆绑包中运行了.jar,它就会一直显示.但是,当通知样式设置为警报"时,以下行将始终记录到控制台:

I'm struggling with the notification center in OS X 10.8. I wrote a wrapper to provide Java access to the NSUserNotification and NSUserNotificationCenter classes via JNA, however the functionality is limited. I am able to send a notification and it will display as long as the .jar is being run from an .app bundle via JavaApplicationStub. However, the line below is always logged to the console when the the notification style is set to "Alerts":

11/29/12 8:37:12.537 PM usernoted[162]: Failed to validate application at (null) -67061

下一步,单击通知将导致以下内容记录到控制台:

Next, clicking the notification results in the following being logged to the console:

11/29/12 8:38:15.291 PM usernoted[162]: Cannot find originating application to launch for event action.  file://localhost/Users/geoffodonnell/Projects/bin/GuiTest.app/ is not the same app as the one that sent the original notification.

我确实为NSUserNotificationCenter类提供了委托,但是这些方法仅在.jar在包外执行时才运行.自然,这将达到目的,因为通知将永远不会显示.

I did provide the NSUserNotificationCenter class with a delegate, however those methods only get run when the .jar is executed outside of a bundle. Naturally, this defeats the purpose since the notification will never be displayed.

任何人都可以提供有关上述两个错误的任何见解吗?

Can anyone provide any insight into the two errors above?

我想知道JavaApplicationStub是否会遇到问题,但是对于典型应用程序如何准确地响应通知中心事件,我却一无所知.

I am wondering if the JavaApplicationStub is getting in the way, however I'm in the dark when it comes to how exactly a typical application would respond the notification center events.

推荐答案

此问题已通过更新到位于此处的JDK 7u10(开发人员预览)来解决,

This issue is solved by updating to JDK 7u10 (Developer Preview) located here,

http://jdk7.java.net/download.html

并使用此处描述的appbundler工具,

And using the appbundler tool described here,

http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

创建您的应用程序捆绑包.该工具使用不同的可执行存根文件创建了一个应用程序捆绑包,因此可能是JavaApplicationStub(和/或JRE 1.6)造成了.

to create your application bundle. This tool creates an application bundle with a different executable stub file, so perhaps JavaApplicationStub (and/or JRE 1.6) was the culprit.

这篇关于通过Java使用OS X 10.8通知中心(NSUserNotification)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆