科尔多瓦插件访问活动自定义的方法 [英] Cordova plugin accessing activity custom method

查看:120
本文介绍了科尔多瓦插件访问活动自定义的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前制作科尔多瓦插件,将有调用哪个开始的主要活动补间动画的方法。

I am currently making a Cordova plugin that will have call a method which starts a tween animation on the main activity.

cordova.getActivity()customMethod();

不起作用,因为该插件不知道方法是否实现与否。我该怎么做呢?

Does not work because the plugin does not know whether the method is implemented or not. How do I do this?

谢谢!

编辑:为了澄清我的问题更好一点?如何使一个科尔多瓦插件在当前活动开始一个Android视图动画

To clarify my question a little bit better: How do I make a Cordova Plugin start an Android view-animation in the current activity?

推荐答案

你加你的插件名称plugins.xml或config.xml中(从2.0.0版本)?

Did you add your plugin name to plugins.xml or config.xml(as from version 2.0.0)?

样 - >

<plugin name="Your_plugin_name" value="packagename.Your_plugin_name"/>

编辑:

当你只是调用您的活动的方法,我不想写一个插件的...但你可以做,只是通过获得从插件活动的引用,并调用method.After所有的插件在本地Java code.But实施,如果你已经实施的 CordovaWebView ,然后代替我宁愿直接从JavaScript调用它。

As you are simply calling a method in your activity,I wouldn't want to write a plugin for that...but you can do that just by getting a reference from that activity in the plugin and calling the method.After all the Plugin is implemented in native Java code.But if you have implemented CordovaWebView,then instead I would rather call it directly from the javascript.

在的onCreate:

In onCreate:

cordovaWebView.getSettings().setJavaScriptEnabled(true);
cordovaWebView.addJavascriptInterface(this, "reference");

在你的活动:

public void animate()
{
   //do animation
}

在JS:

reference.animate();

随你可能会喜欢。

Do as you may like.

这篇关于科尔多瓦插件访问活动自定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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