使用 Android 本机代码作为 Android Titanium 模块

Use Android Native code as Android Titanium Module

我有一个本机 Android Java 代码可以完美编译和运行。我还有一个 Appcelerator Alloy 代码,我需要调用该本机应用程序的一些 Activity 并等待响应事件。 我已经阅读了开发指南 (available here),但是由于我必须使用 TiViewProxy 创建一个结构,所以我被卡住了。

我如何为 Titanium 创建 Android 模块以将该 APK 代码用作 "black box"?

按照以下指南进行操作:https://wiki.appcelerator.org/display/guides2/Android+Module+Architecture 它将解释什么是 TiViewProxy 以及如何使用它。

但是如果您的模块没有使用特殊的 GUI,您就不需要它。如果您使用 appc new 和 select Titanium module 创建一个新模块,您将获得一个默认项目。打开 NameModule.java 文件,在该文件中添加 Android 代码和 use/extend 示例 properties/methods,以便在您的模块和 Titanium 应用程序之间进行通信。

还可以看看其他一些开源模块,例如https://github.com/appcelerator-modules 关于如何实现的东西。

如果您想跳过模块部分,请查看 Hyperloop: https://wiki.appcelerator.org/display/guides2/Hyperloop 和一些例子:https://github.com/appcelerator/hyperloop-examples

也许您的 JAVA 部分可以立即添加到 Titanium