我有一个在WebView中加载网页的应用程序。一旦我打开我的应用程序,如果我在任何一点点击后退按钮它会导致强制关闭。有没有人碰到这个?我不确定我真正想要的是什么。我想禁用后退按钮,因为我的应用程序内置了“后退”功能。但是使用默认的“返回上一页”功能也可以。
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
每次我点击Back LogCat都会给我这个:
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
请注意,使用模拟器时,应用程序不会像在平板电脑上那样崩溃。
答案 0 :(得分:1)
按下后退按钮时,使用以下内容完成您的活动。当然,其他东西可能会导致力量关闭,但如果没有LogCat输出,很难说清楚:
@Override
public void onBackPressed() {
this.finish();
return;
}