通过Cordova Ace插件启动Android活动 [英] start android activity through Cordova Ace Plugin

查看:249
本文介绍了通过Cordova Ace插件启动Android活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将现有的Android项目添加到Cordova Ace项目,并启动本机活动?
如果是,我们如何实现呢?

Is it possible to add an existing android project to Cordova Ace project, and start the native activity? If yes, how do we achieve it?

我有一个Eclipse Android项目这里(带有完整的示例项目代码),并将整个项目代码放在Cordova Ace项目的native文件夹中。但我有很多编译问题。

I've got an Eclipse android project here (with complete Sample Project code) and put the whole project code in the "native" folder of Cordova Ace project. But I got lots of compiled issue.

我已经尝试了几天,但不能实现。

I've tried several days but can't achieve that.

环境:VS 2015 Enterprise,TACO

Environment: VS 2015 Enterprise, TACO

非常感谢您的帮助。

推荐答案

这是可能的。我刚刚添加了一个API,以使这个更容易从JavaScript:

It is possible. I just added an API to make this easier from JavaScript:

ace.android.startActivity("package.MyActivity", 
    function(s) { /* success */ },
    function(e) { /* error */ });

请注意,这是用于启动其他活动。初始活动必须来自CordovaActivity,所以如果你想自定义,你需要修改生成的MainActivity.java文件。

Note that this is for starting additional activities. The initial activity must derive from CordovaActivity, so if you want to customize that, you'll need to modify the generated MainActivity.java file.

此外,不要忘记将您的活动包括在AndroidManifest.xml中。你可以将生成的一个从平台/ android复制到native / android,并在那里进行修改。

Also, don't forget to include your activity in your AndroidManifest.xml. You can copy the generated one from platforms/android into native/android and make modifications there. That way, your copy will overwrite the default one during the build process.

即使没有此API,您通过其他方式调用的Java代码也可以启动一个活动它总是有的方式。我希望有所帮助!我将更新文档。

Even without this API, your own Java code that you invoke via other means can always start an activity the way that it always has. I hope that helps! I'll update the documentation.

这篇关于通过Cordova Ace插件启动Android活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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