{"id":23338746,"url":"https://github.com/appfeel/cordova-annotated-plugin-android","last_synced_at":"2026-04-24T23:32:12.721Z","repository":{"id":57207424,"uuid":"159342080","full_name":"appfeel/cordova-annotated-plugin-android","owner":"appfeel","description":null,"archived":false,"fork":false,"pushed_at":"2019-01-04T12:47:09.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T17:36:53.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appfeel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-27T13:45:02.000Z","updated_at":"2020-06-29T17:58:23.000Z","dependencies_parsed_at":"2022-09-11T05:02:17.076Z","dependency_job_id":null,"html_url":"https://github.com/appfeel/cordova-annotated-plugin-android","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Fcordova-annotated-plugin-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Fcordova-annotated-plugin-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Fcordova-annotated-plugin-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfeel%2Fcordova-annotated-plugin-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfeel","download_url":"https://codeload.github.com/appfeel/cordova-annotated-plugin-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666005,"owners_count":20975785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T03:16:18.395Z","updated_at":"2026-04-24T23:32:07.685Z","avatar_url":"https://github.com/appfeel.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cordova-annotated-plugin-android\u003cbr\u003e[![NPM version][npm-version]][npm-url] [![NPM downloads][npm-downloads]][npm-url]\n\n[npm-url]: https://www.npmjs.com/package/cordova-annotated-plugin-android\n[npm-version]: https://img.shields.io/npm/v/cordova-annotated-plugin-android.svg\n[npm-downloads]: https://img.shields.io/npm/dm/cordova-annotated-plugin-android.svg\n\nWith this plugin, a cordova plugin can be implemented in this way:\n\n```java\npublic class MyPlugin extends AnnotatedCordovaPlugin {\n    @PluginAction\n    private void pluginAction1(int firstOption, String secondOption, CallbackContext callbackContext) {\n        ...\n    }\n}\n```\n\n`AnnotatedCordovaPlugin` extends original `CordovaPlugin`, so all methods are still accessible.\n\nThis plugin helps developers of cordova plugins to forget of the embarrassing and complicated way to develop a cordova plugin.\nUsually the developer had to implement a plugin like this (see [Android Plugin Development Guide](https://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html)):\n\n```java\npublic class MyPlugin extends CordovaPlugin {\n    @Override\n    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {\n        if (\"pluginAction1\".equals(action)) {\n            JSONObject options = args.optJSONObject(0);\n            pluginAction1(options, callbackContext);\n\n        } else if (\"pluginAction1\".equals(action)) {\n            JSONObject options = args.optJSONObject(0);\n            pluginAction2(options, callbackContext);\n\n        } else if (\"moreActions\".equals(action)) {\n            ...\n        } else {\n            LOG.d(\"PLUGIN_TAG\", String.format(\"Unknown action: %s\", action));\n            return false;\n        }\n\n        return true;\n    }\n\n    private void pluginAction1(JSONObject options, CallbackContext callbackContext) {\n        if (options == null) {\n            return new callbackContext.error(\"options is null, please specify options\");\n        }\n        callbackContext.success();\n    }\n}\n```\n\n## PluginAction annotation\nIt has 3 parameters, all of them optional:\n\n- **thread** (*ExecutionThread*): enum, can be MAIN, UI, WORKER (defaults to MAIN)\n- **actionName** (*String*): the name of the method as it will be called from Javascript (defaults to java annotated method name)\n- **isAutofinish** (*boolean*): if `callbackContext.success()` has not been called and `isAutofinish` is set to `true`, when method finishes, `callbackContext.success()` will be called (defaults to `true`)\n\n```java\npublic class MyPlugin extends AnnotatedCordovaPlugin {\n    @PluginAction(thread=ExecutionThread.UI, actionName=\"anotherName\", isAutofinish=false)\n    private void pluginAction1(int firstOption, String secondOption, CallbackContext callbackContext) {\n        ...\n        if (iWantSuccess) {\n            callbackContext.success();\n        } else {\n            callbackContext.error();\n        }\n    }\n}\n```\n\nThen from javascript:\n```js\nmyPlugin.anotherName = function (options, successCallback, failureCallback) {\n    cordova.exec(successCallback, failureCallback, 'MyPlugin', 'anotherName', options);\n};\n\nmyPlugin.anotherName([1, 'second']);\n```\n\n## Agreements\n- Inspired on https://github.com/chemerisuk/cordova-annotated-plugin-android\n\nWhy this rewritting of chemerisuk plugin?\n- Implements proguard defaults\n- Implements auto finish (automatically calls `callbackContext.success()` if it has not been called yet)\n- Documentation has been rewritten\n- Methods have been heavily refactored and simplified to improve maintenance\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfeel%2Fcordova-annotated-plugin-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfeel%2Fcordova-annotated-plugin-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfeel%2Fcordova-annotated-plugin-android/lists"}