Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:36:30+00:00 2026-06-17T20:36:30+00:00

I’ve never developed with java before and i’m trying to figure out how to

  • 0

I’ve never developed with java before and i’m trying to figure out how to launch the Google Navigation app via javascript via phonegap plugin.

I’m trying to modify the phonegap example java class but not having any luck. Here is the class.

appname/src/PhoneNavigator.java

package com.phonegap.plugin.phoneNavigator;

import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Intent;
import android.net.Uri;

/**
 * This class echoes a string called from JavaScript.
 */
public class PhoneNavigator extends CordovaPlugin {
    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("doNavigate")) {
            String message = args.getString(0); 
            this.doNavigate(message,callbackContext);
            return true;
        }
        return false;
    }

    private void doNavigate(String location, CallbackContext callbackContext) {
        if (location != null && location.length() > 0) { 
            callbackContext.success(location);
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location)); 
            startActivity(i);
        } else {
            callbackContext.error("Expected one non-empty string argument.");
        }
    }

    private void startActivity(Intent i) {
        // TODO Auto-generated method stub

    }
}

And then i have the following javascript function

function doNavigate(str){

    str = encodeURIComponent(str);

    cordova.exec(function(winParam) { alert(winParam);}, function(error) { alert(error);}, "PhoneNavigator",
             "doNavigate", [str]);
}

When i run the javascript function in my app i get an alert saying “Invalid action”. On all the examples i’ve seen they just end at “startAcitivity(i);”. When i tried to do that, eclipse told me that i didn’t have that method available. I’m not sure what i’m doing wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:36:31+00:00Added an answer on June 17, 2026 at 8:36 pm

    figured it out with the following.

    package com.phonegap.plugin.phoneNavigator;
    
    import org.apache.cordova.api.CallbackContext;
    import org.apache.cordova.api.CordovaPlugin;
    import org.apache.cordova.api.PluginResult;
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;
    
    import android.content.Intent;
    import android.net.Uri;
    
    /**
     * This class echoes a string called from JavaScript.
     */
    public class PhoneNavigator extends CordovaPlugin {
        @Override
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
            if (action.equals("doNavigate")) {
                String message = args.getString(0); 
                this.doNavigate(message,callbackContext);
                return true;
            }
            return false;
        }
    
        private void doNavigate(String location, CallbackContext callbackContext) {
            if (location != null && location.length() > 0) { 
                callbackContext.success(location);
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location)); 
                this.cordova.getActivity().startActivity(i);
            } else {
                callbackContext.error("Expected one non-empty string argument.");
            }
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.