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);  
        }  求解????

解决方案 »

  1.   

    回复楼上,就是当在程序中添加了上面的代码以后,一启动这个程序是全屏的,但是当你按了电源键->黑屏->电源键->解锁后程序就不是全屏了。我也碰到了楼主一样的问题,不知道楼主解决没?能否共享一下
      

  2.   

    可以试试将TYPE_KEYGUARD换成TYPE_KEYGUARD_DIALOG  试试看吧 
      

  3.   

    home键监听的到吗?貌似监听不到吧。
      

  4.   

    你要想全屏 到xml里面改theme啊记得大概名字叫做nobar..具体忘了 sorry
      

  5.   

    而且这样写不兼容 CM 编译的android系统!
      

  6.   

    如果要屏幕Home键可以在AndroidManifest.xml中配置,不过还是不明白楼主的具体要求,还是告诉大家具体的需求吧,不然大家都不明白你到底想做什么
      

  7.   

    我也碰到这个问题,其实和Home键没有关系,我在View里面只放了一个EditText,关了电源再开,就在屏幕上面出现一条黑的。这个问题已经困扰我一个月了,搜遍了国内外的网站也没有找到解决方案。
    这是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>看看哪位大侠能结了此案!!
      

  8.   

    我找到答案了
    在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);  就不会出现那个问题了。
      

  9.   

    不知道你为什么要屏蔽home键,,按下home键时会回调OnUserLeaveHint()方法, 可以在这里添加按下home键后的操作
      

  10.   

    还是要做处理的,就算离开这个activity都会调用这个方法的