Skip to content

Commit d338752

Browse files
authored
Merge pull request #37 from leonardo-fernandes/outsystems-fix-system-callback
Do not lose callbackContext when opening a SYSTEM url
2 parents 9c9587c + 50bd1c4 commit d338752

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/android/InAppBrowser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public class InAppBrowser extends CordovaPlugin {
164164
*/
165165
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
166166
if (action.equals("open")) {
167-
this.callbackContext = callbackContext;
168167
final String url = args.getString(0);
169168
String t = args.optString(1);
170169
if (t == null || t.equals("") || t.equals(NULL)) {
@@ -175,6 +174,11 @@ public boolean execute(String action, CordovaArgs args, final CallbackContext ca
175174

176175
LOG.d(LOG_TAG, "target = " + target);
177176

177+
final boolean keepCallback = !SYSTEM.equals(target);
178+
if (keepCallback) {
179+
this.callbackContext = callbackContext;
180+
}
181+
178182
this.cordova.getActivity().runOnUiThread(new Runnable() {
179183
@Override
180184
public void run() {
@@ -252,7 +256,7 @@ else if (SYSTEM.equals(target)) {
252256
}
253257

254258
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
255-
pluginResult.setKeepCallback(true);
259+
pluginResult.setKeepCallback(keepCallback);
256260
callbackContext.sendPluginResult(pluginResult);
257261
}
258262
});

0 commit comments

Comments
 (0)