MTK安卓android智能手机如何避免意外的横屏刷屏事件

在配置文件AndroidManifest.xml里面修改:

<application
android:name=”com.fruit.launcher.LauncherApplication”
android:icon=”@drawable/ic_launcher_home”
android:label=”@string/application_name”
android:process=”@string/process” >
<activity

android:configChanges=”orientation|keyboardHidden|mcc|mnc”

……

在Activity的重载方法处理这些config更改事件:

@Override
public void onConfigurationChanged(Configuration arg0) {
// TODO Auto-generated method stub
super.onConfigurationChanged(arg0);

if (arg0.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|| arg0.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}