Android 11強(qiáng)制所有應(yīng)用橫屏展示
1、打開(kāi)
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、
打開(kāi)
frameworks/base/core/java/android/app/Activity.java
文件,對(duì)
setRequestedOrientation
方法進(jìn)行如下修改:
/**
*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
+關(guān)注
關(guān)注
134文章
9027瀏覽量
366476 -
Android
+關(guān)注
關(guān)注
12文章
3917瀏覽量
127036 -
RK3568
+關(guān)注
關(guān)注
4文章
489瀏覽量
4889
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論