I know this may is a duplicate question, i have tried all answers from stack, but non has a complete answer.
Most answers just give how to start an activity but no hints how to configure activity in Android Manifest file and where to save activity layout and manifest file.
Can anyone please give a complete code structure to start an activity from cordova plugin.
Hi you can use this plugin
Usage :
Here is the complete steps to start an activity from a cordova plugin
1. Install Plugman to create plugin
2. Create cordova plugin using plugman
N.B : plugin id never start with Uppercase
Now PluginName directory will be created. Plugin structure will be
3. Add android platform to plugin
Now plugin structure will be
4. Now create a java file named NewActivity.java in src/android diretory
This activity will be shown using our plugin.
NewActivity.java
5. Now create layout file activity_new.xml in src/android diretory
This is the layout file for our new activity
activity_new.xml
6. Now edit PluginName.java in src/android
Now we need to handle the request and start our new activity.
PluginName.java
7. Now edit PluginName.js in www directory
Now create new method to call to start our new activity.
8. Now edit plugin.xml
Now we need to specify our files to plugin and make necessary changes in cordova AndroidManifest.xml file
plugin.xml
9. Now create a cordova project
10. Add android platform to your cordova project
11. Now add your plugin
12. Add a button to index.html in www directory
index.html
13. Add click handler for new button in index.js in www/js directory
When our button is clicked, we will call our plugin method to start our new activity
index.js
14. Now run this app in android phone
If all these steps are success and when we click New Activity button, our new activity will show up.