Created
June 22, 2012 07:03
-
-
Save jmhdez/2970895 to your computer and use it in GitHub Desktop.
Sample Cordova Plugin for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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