读书人

activity onkeydown 单任务 银屏

发布时间: 2013-03-06 16:20:31 作者: rapoo

activity onkeydown 单任务 屏幕改变方向不调用oncreate()方法

//按back建该activity还在? 按home键启动该activity

?@Override
??? public boolean onKeyDown(int keyCode, KeyEvent event)
??? {
??? ? if(keyCode==KeyEvent.KEYCODE_BACK)
???????? {
???????????? return true;
???????? }
??? ?//下面的代码不起作用,这样屏蔽不了home键
??? ? if(keyCode==KeyEvent.KEYCODE_HOME)
??? ? {
??? ?? startActivity(new Intent(this, HomePageActivity.class));
??? ?? return true;
??? ? }


??????? return super.onKeyDown(keyCode, event);
??? }

?

?

?

//单任务 屏幕改变方向不调用oncreate()方法

<activity
android:name="com.example.mxhome.AppCategoryActivity"
android:label="@string/title_activity_app_category"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
</activity>

读书人网 >移动开发

热点推荐