我发现onKeyDown()调用当前选中的视图。有没有办法让我的活动无论关注焦点都能抓住事件?
我的课程如果有兴趣:
MaterialFilePicker filePicker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Start File Picker
filePicker = new MaterialFilePicker();
filePicker.withActivity(this)
.withRequestCode(1)
.withHiddenFiles(true) // Show hidden files and folder
.start();
//Let DataManager prepare the application
DataManager.StartUp(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK) {
DataManager.File = new File(data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH));
startActivity(new Intent(this, SectionChooserActivity.class));
}
}
@Override
public boolean onKeyDown(int keycode, KeyEvent e) {
//This method will never get called :/
switch (keycode) {
case KeyEvent.KEYCODE_MENU:
Stuff();
return true;
}
return super.onKeyDown(keycode, e);
}