简体   繁体   中英

Android app back button causes “Force close”

I have an app that loads a web page, in WebView. Once I've opened my app, if I hit the back button at any point it causes a Force Close. Has anyone run into this? I'm not sure what I really want. I'd like to disable the back button since my app has "Back" built into it. But leaving it with the default "Back to the previous page" functionality would be fine as well.

11-29 18:54:53.393: DEBUG/MediaScannerService(254): done scanning volume external
11-29 18:54:54.403: INFO/InputReader(62): Device reconfigured: id=0x0, name=qwerty, display size is now 320x480
11-29 18:54:54.403: WARN/InputReader(62):   Touch device did not report support for X or Y axis!
11-29 18:54:59.453: INFO/ARMAssembler(62): generated scanline__00000077:03515104_00001004_00000000 [ 65 ipp] (85 ins) at [0x439e0520:0x439e0674] in 5501712 ns
11-29 18:54:59.493: INFO/ARMAssembler(62): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x439e0678:0x439e0840] in 1081228 ns
11-29 18:54:59.653: INFO/ARMAssembler(62): generated scanline__00000177:03515104_00001002_00000000 [ 87 ipp] (110 ins) at [0x439e0848:0x439e0a00] in 610063 ns
11-29 18:55:03.283: WARN/KeyCharacterMap(286): No keyboard for id 0
11-29 18:55:03.283: WARN/KeyCharacterMap(286): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

Each time I click Back the LogCat gives me this:

11-29 18:55:17.303: INFO/InputDispatcher(62): Application is not responding: AppWindowToken{406f1558 token=HistoryRecord{406e7948 com.mysite/.MySite}} - Window{406d90f0 com.mysite/com.mysite.MySite paused=false}.  5026.2ms since event, 5023.1ms since wait started
11-29 18:55:17.303: INFO/WindowManager(62): Input event dispatching timed out sending to com.mysite/com.mysite.MySite

Note that with the emulator the app doesn't crash like it does on my tablet.

Use the following to finish your activity when the back button is pressed. Of course, something else could be causing the force close, but it is hard to tell without the LogCat output:

   @Override
   public void onBackPressed() {
      this.finish();
      return;
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM