Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware back button does not work on device #417

Closed
uzumakinaruto123 opened this issue Mar 31, 2018 · 7 comments
Closed

Hardware back button does not work on device #417

uzumakinaruto123 opened this issue Mar 31, 2018 · 7 comments

Comments

@uzumakinaruto123
Copy link

uzumakinaruto123 commented Mar 31, 2018

Tried capacitor for first time today and built the app successfully. But hardware back button does not work on device.

Back button on navbar works.

Steps I followed:

  1. ionic start capacitorApp sidemenu
  2. npm install --save @capacitor/cli @capacitor/core
  3. npm uninstall --save cordova-plugin-splashscreen
  4. npm run build
  5. npx cap add android
  6. npx cap open android
  7. run app with android studio

On hitting hardware back button app does exit, but page navigation does not work.

Capacitor Info:

   Capacitor Doctor

Dependencies:

  @capacitor/cli: 1.0.0-alpha.32

  @capacitor/core: 1.0.0-alpha.32

  Capacitor Android: not installed

[success] Android looking great! 👌

Ionic Info:


cli packages: (C:\Users\nquser\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

local packages:

    @ionic/app-scripts : 3.1.8
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.4
    npm  : 3.7.3
    OS   : Windows 10

Misc:

    backend : legacy

Device : MiA1(Android 8.1.0)

@mlynch
Copy link
Contributor

mlynch commented Mar 31, 2018

We're not emitting the backbutton event that Cordova did that Ionic relies on, we can fix that

mlynch added a commit that referenced this issue Mar 31, 2018
mlynch added a commit that referenced this issue Mar 31, 2018
@mlynch mlynch closed this as completed in fd9478e Mar 31, 2018
@mlynch
Copy link
Contributor

mlynch commented Mar 31, 2018

K, fixed in master and will be in the next release in a few days

@moda20
Copy link

moda20 commented Aug 22, 2018

Is this, fixed ? I am having the same troubles with back button not exiting.
I do get this on my Android studio console :

V/ViewRootImpl: debug enqueueInputEvent: event = KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=158, metaState=0, flags=0x48, repeatCount=0, eventTime=5988254, downTime=5988089, deviceId=8, source=0x101 },processImmediately = true,mProcessInputEventsScheduled = false, this = ViewRoot{76d403f com.domain.myApp/com.domain.myApp.MainActivity,ident = 0}
V/Capacitor/Plugin/App: Notifying listeners for event backButton
D/WebView: evaluateJavascript=window.Capacitor.fromNative({"save":true,"callbackId":"59221449","pluginId":"App","methodName":"addListener","success":true,"data":{}})
           evaluateJavascript=window.Capacitor.triggerEvent("backbutton", "document")

I am using the ionic 4 beta with :

Capacitor Doctor  💊 

Dependencies:

  @capacitor/cli: 1.0.0-beta.6

  @capacitor/core: 1.0.0-beta.6

  @capacitor/android: 1.0.0-beta.6

  @capacitor/ios: 1.0.0-beta.6

  Capacitor Android: not installed

@jcesarmobile
Copy link
Member

Please, if something doesn’t work report a new issue and provide more information (code used, or even sample app if possible). Don’t comment on old issues as it can be missed

@anRoswell
Copy link

still dont work...

@pubkey
Copy link

pubkey commented Aug 20, 2021

Still does not work on capacitor without ionic.

import { App } from '@capacitor/app';
document.addEventListener('deviceready', () => {
  App.addListener('backButton', (ev: any) => {
    console.log('fire');
  });
});

Edit: I could solve the problem. I loaded my custom plugins the old way, so I got the error capacitor Error: "App" plugin is not implemented on android.
The solution was to switch the the new plugin autoloading like described here.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants