我想检查是否仅在我的上下文菜单中按下了设备上的硬返回键,以便我可以运行意图来重新启动活动。谢谢。到目前为止,这是我的代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
item = menu.add("Something");
item.setIcon(R.drawable.ic_menu_something);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//search
if (item.getTitle() == "Something") {
//how do I check if hard back key was pressed inside this IF statement as to run below intent
Intent myCustomView = new Intent(this, com.example.something.class);
startActivityForResult(myCustomView, RESULT_OK);
}