Skip to content

Commit 50bd1c4

Browse files
Do not lose callbackContext when opening a SYSTEM url
This fixes a condition where it was not possible to open a SYSTEM url while an InAppBrowser instance is displayed. The callbackContext of the InAppBrowser instance was lost when the SYSTEM url was opened. This fixes the issue by not setting the callbackContext on SYSTEM urls.
1 parent 9c9587c commit 50bd1c4

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)