Android – use onbackpressed() with backward compatibility
•
Android
I want to use onbackpressed() method. I still hope to provide support for Android SDK before 2.0. Onbackpressed() was introduced in Android SDK 2.0. But what should I do?
resolvent:
Use onkeydown;
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// Your Code Here
return true;
}
return super.onKeyDown(keyCode, event);
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码