android笔记整理

android笔记整理

------

强制设置横屏

PackageParser.java

 private Activity parseActivity(Package owner, Resources res,
            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError,
            boolean receiver, boolean hardwareAccelerated)
            throws XmlPullParserException, IOException {

....

  a.info.launchMode = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_launchMode,
                    ActivityInfo.LAUNCH_MULTIPLE);
            // add force landscape
            String force_landscape;
            force_landscape = SystemProperties.get("sys.forcelandscape",null);
            if (force_landscape.equals("1")) {
                a.info.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            } else {
                a.info.screenOrientation = sa.getInt(
                        com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation,
                        ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            }
            // add force landscape end
            a.info.configChanges = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_configChanges,
                    0);

 

WindowManager.java

 /**
         * Name of the package owning this window.
         */
        public String packageName = null;
       
        /**
         * Specific orientation value for a window.
         * May be any of the same values allowed
         * for {@link android.content.pm.ActivityInfo#screenOrientation}.
         * If not set, a default value of
         * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
         * will be used.
         */
         // add force landscape
         public int screenOrientation = SystemProperties.get("sys.forcelandscape",null).equals("1")?ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
         // add force landscape end


        /**
         * Control the visibility of the status bar.
         *
         * @see View#STATUS_BAR_VISIBLE
         * @see View#STATUS_BAR_HIDDEN
         */
        public int systemUiVisibility;

 

WindowManagerService.java

   int mLastWindowForcedOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
            ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 

 if (win.mAppToken != null) {
                // We hit an application window. so the orientation will be determined by the
                // app window. No point in continuing further.
                // MStar Android Patch Begin
                return mLastWindowForcedOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
                        ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
                // MStar Android Patch End
 }

int lastOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
                ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

即在有mLastWindowForcedOrientation和lastOrientation的地方,强制设置横屏。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值