Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoneGap on Android : I have a bad information flow between HTML <-> JS <-> PlugIn <-> Activity
    primarykey
    data
    text
    <p>I've got a problem... (Really? :-) )</p> <p><strong>What I want to do?</strong></p> <p>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.</p> <p>So :</p> <p>.HTML Page with JS Events -> .JS PlugIn -> .Java PlugIn -(launch)-> .Java MapActivity</p> <p>And when my MapActivity is finished :</p> <p>MapActivity send [Status.ok] or [message] X-> .Java PlugIn -> .JS CallBack -> Load new page</p> <p><strong>What's the problem?</strong></p> <p>But unfortunately, I have this flow :</p> <p>-> .java Plugin Execute : { Launch(MapActivity); return Response }</p> <p>and then my mapactivity is launched, but my callback is already passed without any data.</p> <p>Another problem : PhoneGap seem's to cancel the onActivityResult(), it's impossible to get callback datas in the MapViewPlugin.java</p> <p><strong>The code?</strong></p> <p><em><strong>mapview.js - Plugin</em></strong></p> <p>Problem with <strong>callBack</strong> 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!</p> <pre><code>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() &lt; dt.getTime()); } </code></pre> <p><em><strong>MapViewPlugin.java - Plugin</em></strong></p> <pre><code>@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); } </code></pre> <p>I don't know if it's the good solution, I am probably in the wrong way. Can anybody help me?</p> <p>It's my first stackoverflow question so if you want more precision or if I am not enough precise, please ask me more details.</p> <p>Thank's!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload