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
}
}
審核編輯 黃宇
-
ARM
+關注
關注
134文章
9306瀏覽量
374985 -
Android
+關注
關注
12文章
3963瀏覽量
129542 -
RK3568
+關注
關注
5文章
577瀏覽量
6079
發布評論請先 登錄
RK3568開發板教程:以iTOP-RK3568開發板為例 Android13通過CIFS協議掛載Windows共享目錄

一文掌握RK3568開發板Android13掛載Windows共享目錄
RK3568的顯示問題及其解決方法
RK3568內置MCU開發介紹之一

Android11修改攝像頭前后置方法,觸覺智能RK3568開發板演示

Android11修改攝像頭前后置方法,觸覺智能RK3568開發板演示

瑞芯微RK3566/RK3568 Android11下該如何默認屏蔽導航欄/狀態欄?看這篇文章就懂了

Android案例分享,基于瑞芯微RK3568國產平臺!

評論