オプション 1: 私自身のデモ テストを通じて、次のコードにより現在のウィンドウを全画面表示できることがわかりました。
private void setWindow(){
WindowManager m = getWindowManager();
Display d = m.getDefaultDisplay(); //为获取屏幕宽、高
android.view.WindowManager.LayoutParams p = getWindow().getAttributes(); //获取对话框当前的参数值
p.height = (int) (d.getHeight()); //高度设置为屏幕的0.6
p.width = (int) (d.getWidth()); //宽度设置为屏幕的0.95
getWindow().setAttributes(p); //设置生效
}
統合アプリにはソース コードがないため、システム ソース コードで setAttributes メソッドの特定の実装を探します。
デバイスの実際の解像度は 1920x1080 ですが、この方法では幅と高さが直接 1920x1080 に再割り当てされます。
オプション II:
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -6671,13 +6671,37 @@ public class Activity extends ContextThemeWrapper
public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {
if (mParent == null) {
try {
- ActivityTaskManager.getService().setRequestedOrientation(
- mToken, requestedOrientation);
- } catch (RemoteException e) {
+// 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);
+ }
+
+ } catch (RemoteException e) {
// Empty
}
} else {
- mParent.setRequestedOrientation(requestedOrientation);
+// mParent.setRequestedOrientation(requestedOrientation);
+ try {
+ if(mApplication != null && mApplication.getApplicationInfo() != null
+ && mApplication.getApplicationInfo().uid > 10000){
+ ActivityTaskManager.getService().setRequestedOrientation(
+ mToken, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }else{
+ mParent.setRequestedOrientation(requestedOrientation);
+ }
+ } catch (RemoteException e) {
+ // Empty
+ }
}
}
diff --git a/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java b/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java
index fb8fd74545c..0f8f7e35c34 100644
--- a/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java
+++ b/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java
@@ -146,7 +146,16 @@ public class ParsedActivityUtils {
sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0),
sa.getInt(R.styleable.AndroidManifestActivity_recreateOnConfigChanges, 0));
- int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);
+ //int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);
+ int screenOrientation;
+ if (pkg.getSharedUserId() == null){
+ screenOrientation = 0;
+ }else{
+ screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);
+ }
int resizeMode = getActivityResizeMode(pkg, sa, screenOrientation);
activity.screenOrientation = screenOrientation;
activity.resizeMode = resizeMode;