Skip to content

Instantly share code, notes, and snippets.

@jmhdez
Created June 22, 2012 07:03
Show Gist options
  • Save jmhdez/2970895 to your computer and use it in GitHub Desktop.
Save jmhdez/2970895 to your computer and use it in GitHub Desktop.
Sample Cordova Plugin for Android
package koalite.cordova;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.apache.cordova.api.PluginResult.Status;
import org.json.JSONArray;
import android.content.Intent;
import android.net.Uri;
public class GoToPlugin extends Plugin {
@Override
public PluginResult execute(String action, JSONArray data, String callbackId) {
try {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + data.getString(0)));
this.ctx.startActivity(i);
return new PluginResult(Status.OK);
}
catch (Exception e) {
System.err.println(e.getStackTrace());
return new PluginResult(Status.ERROR);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment