在 Java 中使用 10.8 通知中心 [英] Using 10.8 Notification Center in Java

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

问题描述

这只是一个普遍的问题.我没有真正的项目或其他我想做的事情.是否可以用 Java 构建应用程序并添加一些框架内容或其他内容并使用通知中心?

解决方案

我写了一个简单的 C -> Objective-C shim .dylib 导出了一个函数 showNotification 立即发送通知.

然后我写了一个 .

用于构建这个简单应用程序的代码是在 github 上提供.它包含一个用于创建 .dylib 的 xcode 项目,以及一个使用 .dylib 来传递通知的 netbeans 项目.

this is just a general question. I'm not having an actual project or something else where I want to do this. Is it possible to build an App in Java and add some framework stuff or something else and use Notication Center?

解决方案

I wrote a simple C -> Objective-C shim .dylib that exported a function showNotification That delivered a notification immediately.

Then I wrote a JNA wrapper to the function exported in the dylib. I'm sure that you could use a combination of Rococoa and JNAerator to eliminate this dylib altogether.

Then I wrote a simple java application that I turned into an app bundle. This is the important point. If your java application is not in an app bundle then notifications will not be delivered.

Messages delivered to the notification center.

It's eminently doable, you just have to play along with the rules of the NSUserNotificationCenter - it must be in an app bundle.

I used java 7, update 9 for this. Another question seems to have had even more success.

The code used to build this simple application is available on github. It contains an xcode project for creating the .dylib, and a netbeans project that makes use of the .dylib to deliver notifications.

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

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