Skip to content

Commit

Permalink
demo android apk 修复8.x独有的不允许设置orientation+背景透明的脑残限制
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Apr 5, 2020
1 parent 2b9e060 commit 63c5c9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Binary file modified app-support-sample/demo_android/app-debug.apk.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Build;
Expand All @@ -18,6 +19,7 @@
import android.widget.Toast;

import java.io.File;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
Expand All @@ -34,6 +36,11 @@ public class MainActivity extends Activity {
private RecordAppJsBridge jsBridge;
@Override
protected void onCreate(Bundle savedInstanceState) {
if(Build.VERSION.SDK_INT>=26 && Build.VERSION.SDK_INT<=27){
//android 8.x 透明+竖屏居然被脑残限制,印度阿三的脑洞吗? https://blog.csdn.net/starry_eve/article/details/82777160
killAndroid8x();
}

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Expand Down Expand Up @@ -339,4 +346,17 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
PermissionCall=null;
}
}

private void killAndroid8x(){
try {
String sadiaoName="mActivityInfo";
Field field = Activity.class.getDeclaredField(sadiaoName);
field.setAccessible(true);
ActivityInfo o = (ActivityInfo)field.get(this);
o.screenOrientation = -1;
field.setAccessible(false);
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 63c5c9f

Please sign in to comment.