简体   繁体   English

如何在Cordova项目的自定义插件中调用android函数?

[英]How to call android functions in a custom plugin in cordova project?

I am new to the cordova plugin development stuff. 我是Cordova插件开发人员的新手。 I want to write a custom plugin which is able to call functions from an android studio project in cordova project. 我想编写一个自定义插件,该插件能够从cordova项目中的android studio项目调用函数。 I follow this tutorial and it works, but instead of the hello world result, I want to call functions and activities of my android studio project and get the results in the cordova project. 我遵循了教程,它可以工作,但是我要调用我的android studio项目的函数和活动,而不是在Hello world中取得结果,并在cordova项目中获取结果。

you can call any functions like regular function in java. 您可以在Java中调用任何函数,例如常规函数。 and to call other activities syntax is 并调用其他活动语法是

cordova.startActivityForResult(this, ringtone, 0); 

after that to get the result call onActivityResult cordova will by default call onActivityResult from the same class you called startActivityForResult 之后,要获取结果,调用onActivityResult科尔多瓦默认情况下会从您调用startActivityForResult的同一类中调用onActivityResult

have a look at my plugin's source file 看一下我插件的源文件

https://github.com/vasani-arpit/cordova-plugin-RingtoneSelector/blob/master/src/android/RingtoneSelector.java https://github.com/vasani-arpit/cordova-plugin-RingtoneSelector/blob/master/src/android/RingtoneSelector.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM