Search code examples
javaandroid-eventj2objc

Handling application events


I am building a cross-platform app for Android and iOS. So far it's mostly Android and I am learning how to use j2objc to translate the code that will later be used by iOS.

On the question of architecture the app - how does one go around passing events in the code that is platform-agnostic. For example, I have a class that downloads a group of files and broadcasts a message using Android broadcast mechanism when each file is downloaded - is there a way to implement this notification exchange in pure Java? Are there any tutorials available?


Solution

  • Guava has an eventbus package, which may meet your needs and is included in the j2objc distribution. To use it, include dist/lib/guava-14.0.1.jar (where "dist" is the path to a recent J2ObjC release) in the j2objc command's -classpath, and link with the -lguava flag.