使用機型是SONY C5,聽說HTC跟紅米也有出現過這樣的問題
(三星TAB S2、Nexus 6P卻完全沒發生過)
情況是:
在A Activity內點擊一個ArrayAdapter
觸發OnItemClickListener之後跳到B Activity
在B Activity按返回鍵會跳回A Activity
然後在A Activity按返回鍵就會失效了
返回鍵的code我是這樣寫:
@Override
public void onBackPressed() {
finish();
}
然後當返回鍵失效的時候,LOG裡面會顯示這幾行:
Key down dispatch to android.widget.GridView{
9933223 VFED.VC. .F....ID 24,48-1056,1347 #7f1001d6 app:id/gridView},
event = KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0,
metaState=0, flags=0x48, repeatCount=0, eventTime=7979073, downTime=7979073,
deviceId=-1, source=0x101 }
Key up dispatch to android.widget.GridView{
9933223 VFED.VC. .F....ID 24,48-1056,1347 #7f1001d6 app:id/gridView},
event = KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0,
metaState=0, flags=0x48, repeatCount=0, eventTime=7979160, downTime=7979073,
deviceId=-1, source=0x101 }
Tracking Key Up, activity is resumed: false
會不會是因為我在Activity裡面有寫這段的關係啊?
@Override
protected void onRestart() {
super.onRestart();
recreate();
}