Search code examples
androidmoduletitaniumappceleratornative

Use Android Native code as Android Titanium Module


I have a native Android Java code that compiles and works perfectly. I also have a Appcelerator Alloy code that I need to call some Activity of that native app and wait for a response event. I've already read the Development Guide (available here) but since I have to create a structure using TiViewProxy I got stuck.

How could I create an Android Module for Titanium to use that APK code as a "black box"?


Solution

  • Follow the next guide at: https://wiki.appcelerator.org/display/guides2/Android+Module+Architecture it will explain what a TiViewProxy is and how to use it.

    But if you module is not using a special GUI you don't need it. If you create a new module with appc new and select Titanium module you'll get a default project. Open the NameModule.java file add your Android code and use/extend the example properties/methods inside that file to communicate between your module and your Titanium App.

    Also have a look at some other open source modules e.g. https://github.com/appcelerator-modules on how to implement stuff.

    And if you want to skip the module part have a look at Hyperloop: https://wiki.appcelerator.org/display/guides2/Hyperloop and some examples: https://github.com/appcelerator/hyperloop-examples

    Perhaps your JAVA part can be added to Titanium right away