1.问题描述:
在4.1的系统下,调试机器是768*1024的
默认使得在launcher 是,状态栏显示menu键,但是按下menu键时却没有相应界面弹出,
但是原来的机器:1024*600的就没有任何问题
1)查找原因:
launcher代码问题,通过不同的机器对比同样的代码,证明代码没有问题
资源布局问题:强行走1024*600的布局,证明布局没有问题
唯一区别代码尺寸不同,最后只能追查menu键按下的处理过程,最终确认原因。
2)确认问题原因:
menu键按下处理的关键:
文件:
PhoneWindow.java (frameworks\base\policy\src\com\android\internal\policy\impl)
按键按下后会走到一下的两个文件:
public final boolean onKeyDownPanel(int featureId, KeyEvent event) {
}
public final void onKeyUpPanel(int featureId, KeyEvent event) {
...
openPanel(st, event);
...
}
private void openPanel(PanelFeatureState st, KeyEvent event) {
// System.out.println("Open panel: isOpen=" + st.isOpen);
// Already open, return
if (st.isOpen || isDestroyed()) {
return;
}
// Don't open an options panel for honeycomb apps on xlarge devices.
// (The app should be using an action bar for menu items.)
if (st.featureId == FEATURE_OPTIONS_PANEL) {
Context context = getContext();
Configuration config = context.getResources().getConfiguration();
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
boolean isHoneycombApp = context.getApplicationInfo().targetSdkVersion >=
android.os.Build.VERSION_CODES.HONEYCOMB;
if (isXLarge && isHoneycombApp) {
return;
}//这里就是问题的原因
}
...
}
3)//问题分析,条件有两个
isXLarge 和 isHoneycombApp
isXLarge 为真:
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
分析:文件:WindowManagerService.java (frameworks\base\services\java\com\android\server\wm)
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh) {
...
// configuration. DO NOT CHANGE!
if (longSize < 470) {
// This is shorter than an HVGA normal density screen (which
// is 480 pixels on its long side).
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_SMALL;
screenLayoutLong = false;
screenLayoutCompatNeeded = false;
} else {
// What size is this screen screen?
if (longSize >= 960 && shortSize >= 720) {
// 1.5xVGA or larger screens at medium density are the point
// at which we consider it to be an extra large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_XLARGE;//系统走的是这里,原因
} else if (longSize >= 640 && shortSize >= 480) {
// VGA or larger screens at medium density are the point
// at which we consider it to be a large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_LARGE;
} else {
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_NORMAL;
}
...
}
4)解决方法:在函数中屏蔽掉,问题解决,按menu键后弹出选项:
private void openPanel(PanelFeatureState st, KeyEvent event) {
if (isXLarge && isHoneycombApp) {
;//return;//屏蔽掉
}//这里就是问题的原因
}
详细解决方案
相关解决方案
- android 读取byte[]中的元素解决方案
- android 标题栏兑现方式
- android 中Activity向BroadcastReceiver发送数据,该怎么解决
- Android 4.0 为什么模拟器老是提示小弟我谷歌拼音输入法已停止
- android:getSharedPreferences() 这是哪个类的方法解决思路
- android 怎么判断一个程序是否联网
- android RadioButton如何设置默认选中
- j2me中在canvas下加入多个同等优先级的Command.Item类型命令,系统给归并到一个"menu"下,请教怎么更改menu的名字?
- android 怎么重新设置锚点
- android 图片对象获取的有关问题
- android 关于服务连接的疑义
- android 怎么实现对view的放大和缩小
- android ID,该如何处理
- 准备复习2-3个月,看java+android,请问有经验者,怎么看效果最好》
- android UI线程与AsyncTask的有关问题
- android(java) 中文乱码的有关问题
- android 动态设立控件高度
- Android test project 编译方法
- MTK:menu item文本显示有关问题
- android 4.03启动出错,显示"Encryption Unsuccessful"该如何解决
- Android 下面的listView的动态效果怎么实现的?求源代码,多谢
- Android?Palm?Symbian?Windows Mobile?学哪个有“钱图”?解决方案
- Android 开发语言,该怎么解决
- 单个人去做手机开发选什么平台好?android,iphone?解决办法
- Android 虚拟机崩溃的有关问题
- Android 上的如何读写设备文件
- Android 2.2 API 汉语文档系列(3) —— AccessibilityService
- 【先睹为快】ArcGIS Android SDK上一版本新特性
- ArcGIS for Android app v2.0.4公布
- android.hardware.USB种介绍