In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Android5.0 above for APP_SWITCH and HOME key handling is like, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
In the case of android5.0 project development, the HOME key needs to be captured. After searching, the implementation function is as follows:
Add the following functions to framework/base/services/core/java/com/android/server/policy/PhoneWindowManager.java:
Private boolean getTopStackActivity (String fullClassName) {
ActivityManager am = (ActivityManager) mContext.getSystemService (Context.ACTIVITY_SERVICE)
RunningTaskInfo info = am.getRunningTasks (1) .get (0)
If (info = = null | | info.topActivity = = null) {
Log.e (TAG, "Top activity is null, error")
Return false
}
If (fullClassName.equals (info.topActivity.getClassName () {
Log.d (TAG, "Top Activity:" + info.topActivity.getClassName ())
Return true
}
Return false
}
HOME key processing:
Add the above function to the if (keyCode = = KeyEvent.KEYCODE_HOME) of the interceptKeyBeforeDispatching function to capture the HOME key at the application layer.
APP_ switch key processing:
Add the above function to if (keyCode = = KeyEvent.KEYCODE_APP_SWITCH) under else if (keyCode = = KeyEvent.KEYCODE_MENU) of the interceptKeyBeforeDispatching function to capture the APP_ switch key in the application layer.
After reading the above, have you mastered how android5.0 handles APP_SWITCH and HOME keys? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.