方案一:通过自己的demo测试得知,如下代码可以让当前窗口全屏显示
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); //设置生效
}
由于集成的app没有源码,所以在系统源码中查找setAttributes方法的具体实现。
设备实际分辨率为 1920x1080,在此方法中直接重新赋值 宽高为1920x1080
方案二:
--- 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;