专栏中心

EEPW首页 > 专栏 > RK3568开发平台Android 11强制所有应用横屏展示

RK3568开发平台Android 11强制所有应用横屏展示

发布人:TQwangbin 时间:2023-12-28 来源:工程师 发布文章
Android 11强制所有应用横屏展示  

1、打开frameworks/base/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java文件,定位到parseActivityOrReceiver方法的int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);这一行,注释掉该行并添加如下代码:// int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);            
// Edit by jgduan            
int screenOrientation;            
if(pkg.getSharedUserId() == null){            
    screenOrientation = 0;            
} else {            
    screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);            
}            
// End            
2、打开frameworks/base/core/java/android/app/Activity.java文件,对setRequestedOrientation方法进行如下修改:    /**            
     * Change the desired orientation of this activity.  If the activity            
     * is currently in the foreground or otherwise impacting the screen            
     * orientation, the screen will immediately be changed (possibly causing            
     * the activity to be restarted). Otherwise, this will be used the next            
     * time the activity is visible.            
     *            
     * @param requestedOrientation An orientation constant as used in            
     * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.            
     */            
    public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {            
        if (mParent == null) {            
            try {            
                // Edit by jgduan            
                //ActivityTaskManager.getService().setRequestedOrientation(            
                //        mToken, requestedOrientation);            
                if(mApplication != null && mApplication.getApplicationInfo() != null            
                    && mApplication.getApplicationInfo().uid > 10000){            
                    ActivityTaskManager.getService().setRequestedOrientation(            
                            mToken, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);            
                } else {            
                    ActivityTaskManager.getService().setRequestedOrientation(            
                            mToken, requestedOrientation);            
                }            
                // End            
            } catch (RemoteException e) {            
                // Empty            
            }            
        } else {            
            // Edit by jgduan            
            // mParent.setRequestedOrientation(requestedOrientation);            
            if(mApplication != null && mApplication.getApplicationInfo() != null            
                    && mApplication.getApplicationInfo().uid > 10000){            
                mParent.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);            
            }else{            
                mParent.setRequestedOrientation(requestedOrientation);            
            }            
            // End            
        }            
    }            
    



-END-


专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词: 嵌入式 ARM开发

相关推荐

意法半导体出厂中国制造的STM32 MCU

Windows CE 开发初步(第一部)

汽车存储器新突破:8nm128Mb嵌入式MRAM的研发

RK3576 + ROS2 SLAM建图与导航实战

从COM到SMARC再到OSM:嵌入式计算模块的发展

展会预告!米尔邀您相约德国嵌入式展 2026Embedded World

IAR 扩展了嵌入式开发平台,提供 LTS 服务

浅谈嵌入式LINUX系统教与学

资源下载 2007-02-09

华清远见嵌入式在线视频教程——1、走近嵌入式系统

视频 2008-07-08

华清远见嵌入式在线视频教程——4、基于ARM的嵌入式开发

视频 2008-07-14

米尔亮相德国嵌入式展2026 Embedded World

嵌入式看门狗如何提升系统稳定性

第一讲:嵌入式系统概述

未来倾向于UFS用于高性能嵌入式闪存

陈渝大侠翻译的 uClinux2.6入门

嵌入式系统方案设计

TI将边缘AI微控制器更深入地融入嵌入式设计

更多 培训课堂
更多 焦点
更多 视频

技术专区