Skip to main content

Posts

Showing posts from November, 2016

Start an android activity from cordova plugin

We all need to start an android activity from a cordova plugin. Here is a small and complete code to start an activity from cordova plugin
1. Install plugman to create cordova plugin npm install -g plugman2. Create cordova plugin using plugman plugman create --name PluginName --plugin_id com.example.sample.plugin --plugin_version 0.0.1
N.B : plugin id never start with Uppercase Now PluginName directory will be created. Plugin structure will be
> PluginName/

> |- plugin.xml

> |- src/

> |- www/PluginName.js

3. Add android platform to plugin
plugman platform add --platform_name android Now plugin structure will be

> PluginName/

> |- plugin.xml

> |- src/android/PluginName.java

> |- www/PluginName.js

4. Now create a java file named NewActivity.java in src/android diretory
This activity will be shown using our plugin. Write sample activity in NewActivity.java
package com.example.sample.plugin;

import android.app.Activity;
import android.os.Bundle;

public…