android这样屏蔽home键后和全屏冲突,屏蔽home键,就没有全屏了。private boolean catchHomeKey = false;
@Override
public void onAttachedToWindow() {
// TODO Auto-generated method stub
if(catchHomeKey) {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
super.onAttachedToWindow();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_HOME) {
Log.e(TAG, "Home key down");
}
return super.onKeyDown(keyCode, event);
} 求解????
@Override
public void onAttachedToWindow() {
// TODO Auto-generated method stub
if(catchHomeKey) {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
super.onAttachedToWindow();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_HOME) {
Log.e(TAG, "Home key down");
}
return super.onKeyDown(keyCode, event);
} 求解????
这是AndroidManifest.xml:
<application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="@string/app_name" android:icon="@drawable/icon" android:allowClearUserData="false">
<activity android:name=".HanyuActivity" android:label="@string/app_name" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
以下是出程序:只贴关键部分了
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//全屏
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
wv = (EditText) findViewById(R.id.editText1);
wv.setText("abcd");
}
以下是mail.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" android:weightSum="1">
<EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="match_parent">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>看看哪位大侠能结了此案!!
在AndroidManifest.xml里设置
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
可以将你的Home键的默认启动改为你的程序,这样就不需要在程序里去屏蔽它了。
去掉getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 就不会出现那个问题了。