//按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>