You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/01/02 05:47:21 UTC

[GitHub] [cordova-plugin-inappbrowser] nomaam opened a new issue #835: hardware back button hide inappbrowser

nomaam opened a new issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835


   
   I am trying to control the hardware back button for Android in Java file
   
       InAppBrowserDialog.java
   
       public void onBackPressed() {
       if (this.inAppBrowser == null) {
           this.dismiss();
       } else {
           if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
               // this.inAppBrowser.goBack();
           } else {
               // this.inAppBrowser.closeDialog();
           }
       }
       }
   
       }
   
   I do not want it to "goBack" or "closeDialog", I want it to "hide", like you can call it on the Cordova Javascript side
   
       https://github.com/apache/cordova-plugin-inappbrowser#inappbrowserhide
   
       ref.hide();
   
   Hide is ideal so I can call .show if I want without loading the entire page, which is what would happen if I just closed it.
   
   I am looking for a Java command such as
   
       this.inAppBrowser.hide();
   
   But I can't seem to find it.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] nomaam commented on issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
nomaam commented on issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835#issuecomment-753490865


   
   > The in app browser does have a `hide` API. See https://github.com/apache/cordova-plugin-inappbrowser#inappbrowserhide for more details.
   > 
   > Is this not sufficient?
   
   I already linked that function in my original post... and described why it is not ideal... 
   
   On an Android phone there is a physical (hardware) back button, unlike on an iPhone where there is none. A user will expect the physical back button to be functional, otherwise they will most likely get frustrated. 
   
   Currently the only functions the physical back button can do inside inAppBrowser is go back a page, or exit the inAppBrowser. 
   
   This is not ideal, as if you want to use the inAppBrowser again you will have to load the page / reasource all over again, which takes a lot of time, plus the user will lose their spot where they left off in the inAppBrowser session. 
   
   Ideally, the physical back button would call the Cordova .hide function from the Java function I originally posted. Then you could call .show in Cordova Javascript and the user would be able to resume where they left off in the inAppBrowser. 
   
   Is there any way to directly call the Javascript Cordova .hide inAppBrowser function from within the Java file?
   
   Thanks.
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] breautek commented on issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835#issuecomment-753492947


   Have you tried attaching the [backbutton](https://cordova.apache.org/docs/en/dev/cordova/events/events.html#backbutton) listener?
   
   I'm not sure if this will work when the inappbrowser is active, but you could try hooking into that event to call the JS `hide` api on your browser reference.
   
   ```javascript
   
   document.addEventListener('backbutton', function () {
       var ref = getBrowserReferenceSomehow();
       if (ref) {
          ref.hide();
       }
       else {
           window.history.back();
       }
   });
   ```
   
   > Is there any way to directly call the Javascript Cordova .hide inAppBrowser function from within the Java file?
   
   The only way this is possible is if you fork and maintain your own version of this plugin, which I personally wouldn't recommend. When you call the JS `hide` api, it will reach:
   
   https://github.com/apache/cordova-plugin-inappbrowser/blob/8bdbd18d1619e25cf8bdedadf6448ef40b21ea7c/src/android/InAppBrowser.java#L329-L341
   
   You could probably modify this and abstract it so you can call the hide method from elsewhere within the native code side.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] nomaam commented on issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
nomaam commented on issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835#issuecomment-759920366


   after some effort, the hardware back button is now linked to the cordova .hide function in the inappbrowser. tested and working. 
   
       https://stackoverflow.com/questions/65534821/cordova-inappbrowser-hide-show-in-java-android
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] nomaam commented on issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
nomaam commented on issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835#issuecomment-753498011


   I have tried the back button listener in Cordova, and it does not fire when the inappbrowser is active. 
   
   Thank you for posting the Java code that is linked to .hide Javascript function, that is very helpful. I am not well versed in Java so am trying to figure out how to get that function to be called within the Java back button. 
   
   I will post if for others if I am able to figure it out. 
   
   Thanks again, much appreciated. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] nomaam closed issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
nomaam closed issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-inappbrowser] breautek commented on issue #835: hardware back button hide inappbrowser

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #835:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/835#issuecomment-753486314


   The in app browser does have a `hide` API. See https://github.com/apache/cordova-plugin-inappbrowser#inappbrowserhide for more details.
   
   Is this not sufficient?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org