Using OS X 10.8 Notification Center (NSUserNotification) with Java
Asked Answered
C

1

6

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.

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?

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.

Coneflower answered 30/11, 2012 at 2:18 Comment(3)
Is this wrapper open-source by any chance?Vachell
Holy smokes, I don't know if it's still relevant @Vachell but I'll see if I can dig it up for you.Coneflower
@Vachell Yes! It's here: github.com/gbosystems/GSInstrumentedAndroidBluetoothConeflower
C
2

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

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

And using the appbundler tool described here,

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

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.

Coneflower answered 9/12, 2012 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.