thaarok / cordova-plugin-kiosk

Cordova plugin to use Cordova application "in kiosk mode" and as Android launcher
Apache License 2.0
142 stars 101 forks source link

App crash when tried to hit back button #53

Closed krishna711 closed 6 years ago

krishna711 commented 6 years ago

Hi, Plugin is work fine but there is flaw in it. Sometimes it crash when we use back button or any button. Back button not blocked on some device as well. App crash allow user to open other apps in the device.

It there any fix for this issue?

thaarok commented 6 years ago

Hi, can you provide stacktrace or any debug info which would help to determine why has the app crashed?

krishna711 commented 6 years ago

I can but not sure how to generate stacktrace for ionic app. When app crash it closed and nothing shows up. If you have any idea let me know so you I can provide relevant info.

thaarok commented 6 years ago

Run adb logcat command (from platform-tools in android sdk) while the device is connected in usb debug mode. Try to catch the exception which will arrive in the log when the application crash. https://developer.android.com/studio/command-line/logcat

krishna711 commented 6 years ago

Thank you. I will check exception via this method. I noticed another issue. In one device, back button does not lock. Only home button, and option button lock. Back button always open to use. Device run on Android 5.0. Please check this issue as well.

krishna711 commented 6 years ago

Attached logcat log during app crash. Device nexus, android 7.1.1 logcat.txt

thaarok commented 6 years ago

Can you send your /data/anr/traces.txt mentioned in your logcat.txt?

thaarok commented 6 years ago

Regarding the back button, open standalone issue and provide appropriate logcat output too please. (does "onKeyDown event: keyCode = ..." appear in the log?)

krishna711 commented 6 years ago

Here traces.txt file. I will open standalone issue for back button and send logcat separately. Thanks traces.txt

krishna711 commented 6 years ago

Did you find anything? Please update if possible. I can also send you apk file if needed. Also, I tried your demo app which works fine. The only difference I found is that demo app built in ionic version 1 while my app built on ionic 3. Other plugins list if that helps.

cordova-plugin-device 2.0.2 "Device" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 1.1.19 "cordova-plugin-ionic-webview" cordova-plugin-kiosk 0.2 "Cordova Kiosk Mode" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-whitelist 1.3.3 "Whitelist"

thaarok commented 6 years ago

Hi, sorry, provided logs has not give me any hint what could be the issue. If you can send reproducing app, it will be very helpful.

krishna711 commented 6 years ago

Yes, attached apk file. It is simple quiz app. Quiz logic is coded in typescript and jquery. Nothing changed or customised on ionic or plugin level. Thanks a lot for help.

bizz-quiz.0.0.3.apk.zip

thaarok commented 6 years ago

It looks related to InAppBrowser: there is option hardwareback:

thaarok commented 6 years ago

If you will not by able to fix it that way, as a workaround, you can implement custom back button handler in Ionic: https://ionicframework.com/docs/api/platform/Platform/#registerBackButtonAction

krishna711 commented 6 years ago

Thanks a lot.. It worked. Do you have any idea on disable option/recent history button as well?

Thanks

thaarok commented 6 years ago

Kiosk plugin rely on fact its activity is only thing allowed on screen - when KioskActivity lost a focus, it kills all system dialogs. But InAppBrowser is non-system Dialog, which mean it is not killed, but when something tries to cover it (like recent apps menu), KioskActivity will not kill it as it has not focus already. Modified version of InAppBrowser plugin would be necessary. (Maybe could be provided as part of kiosk plugin directly...) Are you sure you need InAppBrowser? If the displayed web page is trusted, you can embed it in