Search code examples
javascriptjavaandroidcordovaphonegap

How to use existing android app as cordova plugin


I have build an android app with help of quasar and cordova.

Now I want to add print function that is actually device specific (e.g. mpos device).

I have uploaded the source code of native android project that i want to use in my cordova project repo of android source code.

I want to call printText function into cordova-plugin from native android link to printText function

something similar like below:

exports.print= function (arg0, success, error) {
  exec(success, error, 'PrintDevActivity', 'printText', [arg0]);
}

I need help in these two things:

  1. how many files i need to copy from above repo of android project to my cordova plugin

  2. what changes i need to do in cordova plugin plugin.xml so it will work.

I am confused , should i need to copy only .java files or also gradle etc.

This is my plugin.xml file of cordova plugin

plugin.xml

Any help or suggestion will highly appreciated.

Thank you


Solution

  • As per your question, I think you need to build cordova plugin for any android sdk. Please check below link, i think this is have lot of information about building cordova plugin with any existing sdk or code.

    building-a-cordova-plugin-for-your-native-sdk

    I hope this will help you. Thanks