添加原生code到现有的工作灯的混合应用程序 [英] Adding native code to an existing Worklight hybrid app

查看:174
本文介绍了添加原生code到现有的工作灯的混合应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android运行的工作灯混合应用程序,我想添加一些功能来调入当前未通过工作灯或科尔多瓦提供了原生的Andr​​oid库。我的理解是,我需要创建一个插件科尔多瓦做到这一点。创建科尔多瓦插件似乎pretty直截了当给出的步骤在<一个解释href=\"http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v620/07_05_Android_-_Adding_native_functionality_to_hybrid_application_with_Apache_Cordova_plugin.pdf\"相对=nofollow>入门教程。

I have a worklight hybrid app running on android and I wanted to add some functionality to call into a native android library that isn't currently provided via worklight or cordova. My understanding is I'll need to create a cordova plugin to do this. Creating the cordova plugins seems pretty straight forward given the steps explained in the Getting started tutorial.

的模式挂断我已经是当我去创建Java类来实现的插件。该教程称通过创建一个插件的Java类开始...但它并没有真正说'这里'创建它。在工作​​灯工作室,每当我去创建一个新的Java类(右键点击工作灯项目>新建>类),它希望在项目/服务器/ java目录创建它。

The one hang-up I have is when I go to create the Java class to implement the plugin. The tutorial says "Start by creating a Java class for a plug-in"... but it doesn't really say 'where' to create it. In Worklight Studio, whenever I go to create a new java class (Right click worklight project > New > Class) it wants to create it in the Project/server/java directory.

纵观教程样本code,它看起来像我应该能够在项目/应用程序创建一个新的类/名/安卓/ nativeResources / src目录,因为这是示例类创建,其中,但在任何这些目录中右击并没有列出的Java类作为一个选项(短要去其他,并拿起它那里)。此外,有nativeResources目录下,从我的经验,没有src目录,该目录需要通常由日食创建。

Looking at the tutorial sample code, it looks like I should be able to create a new class in the Project/Apps/name/android/nativeResources/src directory, as that is where the example class was created, but right clicking on any of those directories doesn't list a "Java Class" as a option (short of going to "Other" and picking it there). Also, there is no 'src' directory under the nativeResources directory and from my experience, that directory is typically created by eclipse as needed.

我也尝试创建一个原生API分项目,看看是否能够生成所需的目录,但它没有,似乎是无关的什么我想要实现的。

I also tried creating a "Native API" sub-project to see if that would generate the needed directories but it did not and seems to be unrelated for what I want to achieve.

所以,最终的问题是我应该只是手动创建nativeResources文件夹下的目录,并添加在我的新类(即使日食/工作灯工作室似乎并没有认识到,作为一个有效的位置),还是我完全缺少的东西?

So the ultimate question is should I just manually create the directories under the nativeResources folder and add in my new class (even though eclipse / worklight studio doesn't seem to recognize that as a valid location) or am I totally missing something?

推荐答案

该NativeAPI选项是为本地应用开发。由于这是不是你要找的东西,这不是使用的选项。

The NativeAPI option is meant for native application development. As this is not what you're looking for, this is not the option to use.

该nativeResources文件夹由工作灯为方便起见提供的(你可以搜索堆栈溢出为[工作灯] nativeResources,你会发现很多阅读材料)。使用此文件夹,您可以存储在本地实际每夹其位置的各种文件,并在构建时工作灯生成器将取代您放置在nativeResources文件夹中的文件的任何本地文件夹的内容。

The nativeResources folder is provided by Worklight for the sake of convenience (you can search Stack Overflow for "[worklight] nativeResources", you'll find plenty of reading material). Using this folder you can store various files per their location in the actual native folder, and upon build time the Worklight Builder will replace the contents of the native folder with whatever files you've placed in the nativeResources folder.

由于它是只是一个文件夹,右键单击它不会做了。

Because it's "just a folder", right-clicking it will not do much.

对类文件添加到,就像在任何Android应用程序的地方(这是不是唯一的工作灯),是在本地\\ src文件夹中(原生的\\ src \\ COM \\ APP_NAME)。本机文件夹是生成的Andr​​oid项目的重新presentation。

The place to add the class file to, just like in any Android application (this is not unique to Worklight), is in the native\src folder (native\src\com\app_name). The native folder is a representation of the generated Android project.

所以,你可以创建该文件要么在本地文件夹,或在生成的Andr​​oid项目。结果
如果您在生成的Andr​​oid的文件夹中创建它,你这时就需要回到复制到相同的位置在本地文件夹中,这样,工作灯将它运行一个Build下一次添加到您的生成Android项目(运行方式>工作灯开发服务器上运行)。

So you can create this file either under the native folder, or in the generated Android project.
If you create it in the generated Android folder, you'll then need to copy it back to the same location in the native folder, so that Worklight will add it to your generated Android project the next time you run a Build (Run As > Run on Worklight Development Server).

这篇关于添加原生code到现有的工作灯的混合应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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