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

  • Home
  • SEARCH
  • 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 6872643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:57:19+00:00 2026-05-27T03:57:19+00:00

I’ve got a problem… (Really? :-) ) What I want to do? I need

  • 0

I’ve got a problem… (Really? 🙂 )

What I want to do?

I need to make a native plugin to launch a MapActivity (to show POI, show itineraries, …), and when the mapView is closed with some conditions, I have to load a particular html page.

So :

.HTML Page with JS Events -> .JS PlugIn -> .Java PlugIn -(launch)-> .Java MapActivity

And when my MapActivity is finished :

MapActivity send [Status.ok] or [message] X-> .Java PlugIn -> .JS CallBack -> Load new page

What’s the problem?

But unfortunately, I have this flow :

-> .java Plugin Execute : { Launch(MapActivity); return Response }

and then my mapactivity is launched, but my callback is already passed without any data.

Another problem : PhoneGap seem’s to cancel the onActivityResult(), it’s impossible to get callback datas in the MapViewPlugin.java

The code?

mapview.js – Plugin

Problem with callBack which is called before the MapActivity is launched.
The sleep(2000) is a workaround to show the new page after the MapView is shown. But it’s not a good issue!

MapView.prototype.showItineraryMapView = function(itineraryEncoded, startLat,
        startLong, startTitle, startDesc, finishLat, finishLong, finishTitle,
        finishDesc, callBack) {
    PhoneGap.exec(function() {
        sleep(2000);
        callBack();
    }, function(){} , "MapView", "show_itinerary", [ itineraryEncoded, startLat, startLong,
            startTitle, startDesc, finishLat, finishLong, finishTitle,
            finishDesc ]);
};

function sleep(ms) {
    var dt = new Date();
    dt.setTime(dt.getTime() + ms);
    while (new Date().getTime() < dt.getTime());
}

MapViewPlugin.java – Plugin

@Override
public PluginResult execute(String action, JSONArray data, String callbackId)
{
    Log.i("MapViewPlugin", "Début MapViewPlugin");

    PluginResult result = null;
    if (action.equals(ACTION_SHOW_ITINERARY))
    {
        Log.i("MapViewPlugin", "showItineraryMapView");
        try
        {
            return this.showItineraryMapView(data.getString(0), data.getInt(1), data.getInt(2), data.getString(3), data.getString(4), data.getInt(5), data.getInt(6), data.getString(7), data.getString(8));
        }
        catch (JSONException e)
        {
            e.printStackTrace();
        }
    }
    else
    {
        result = new PluginResult(Status.INVALID_ACTION);
        Log.d("MapViewPlugin", "Invalid action : " + action + " passed");
    }
    return result;
}
private PluginResult showItineraryMapView(String encoded_itinerary, int startLat, int startLong, String startTitle, String startDesc, int finishLat, int finishLong, String finishTitle, String finishDesc)
{
    Log.i("MapViewPlugin", "Start showMapView()");
    Intent iMapView = new Intent(ctx, MapViewActivity.class);
    iMapView.putExtra(MODE, MODE_ITINERARY);
    iMapView.putExtra(ITINERARY_ENCODED, encoded_itinerary);
    iMapView.putExtra(START_LAT, startLat);
    iMapView.putExtra(START_LONG, startLong);
    iMapView.putExtra(START_TITLE, startTitle);
    iMapView.putExtra(START_DESC, startDesc);
    iMapView.putExtra(FINISH_LAT, finishLat);
    iMapView.putExtra(FINISH_LONG, finishLong);
    iMapView.putExtra(FINISH_TITLE, finishTitle);
    iMapView.putExtra(FINISH_DESC, finishDesc);

    Log.i("MapViewPlugin", "Launching intent...");

    ctx.startActivity(iMapView);

    return new PluginResult(Status.OK);
}

I don’t know if it’s the good solution, I am probably in the wrong way. Can anybody help me?

It’s my first stackoverflow question so if you want more precision or if I am not enough precise, please ask me more details.

Thank’s!

  • 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-05-27T03:57:19+00:00Added an answer on May 27, 2026 at 3:57 am

    It’s not quite right. Here are a few changes that should get you unstuck. First you’ll need to save the callbackId that is passed into execute. Then in your execute method call showItineraryMapView() but don’t get it to return a PluginResult have it return void.

    Immediately after you make the call to showItineraryMapView() do this:

    PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
    r.setKeepCallback(true);
    return r;
    

    Then in showItineraryMapView() you want to call ctx.startActivityForResult() instead of ctx.startActivity() and remove the line immediately afterwards that returns a new PluginResult.

    Then you’ll need to over-ride the onActivityResult() method. This is where you’ll get your information from MapView. Then you end up calling:

    this.success(new PluginResult(PluginResult.Status.OK, myData), this.callbackId);
    

    where “myData” is the information you want to pass back to the JavaScript side and “this.callbackId” is the callback ID you stored in the execute method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
i got an object with contents of html markup in it, for example: string

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.