android设置系统横屏方案
效果如下:
实现方案:
1、ChangeOrientationService.java
/**
* @描述 强制旋转屏幕服务
* @作者 tll
* @时间 2018/1/5
*/ public class ChangeOrientationService extends Service {
private final IBinder mBinder = new LocalBinder(); @Nullable
@Override
public IBinder onBind(Intent intent) {
return mBinder;
} @Override
public int onStartCommand(Intent intent, int flags, int startId) {
WindowManager mWindow = (WindowManager) getSystemService(WINDOW_SERVICE);
CustomLayout mLayout = new CustomLayout(intent.getIntExtra("orientation", 0));
mWindow.addView(new View(this), mLayout);
stopSelf();
return START_NOT_STICKY;
} public class LocalBinder extends Binder {
public LocalBinder() {
super();
}
} public class CustomLayout extends android.view.WindowManager.LayoutParams {
public CustomLayout(int paramInt) {
// TYPE_SYSTEOM_OVERLAY:the layer that is on the top of the window(位于窗口顶部的层)
super(0, 0, TYPE_SYSTEM_OVERLAY, FLAG_FULLSCREEN | FLAG_NOT_FOCUSABLE, PixelFormat.RGBX_8888);
// push object to the top of its container, not changing its size.(将对象推到容器的顶部,而不是改变其大小。)
this.gravity = Gravity.TOP;
// set the screenOrientation as desired(按需要设置屏幕方向)
this.screenOrientation = paramInt;
}
}
}
2.AndroidManifest.xml
<service
android:name=".services.ChangeOrientationService"
android:permission="android.permission.WRITE_SETTINGS"/>
3.fragment里面使用
/**
* 请求用户给予悬浮窗的权限
*/
public boolean askForOverlayPermission() {
if (!MyWindowManager.checkPermission()) {//检测悬浮窗权限
MyWindowManager.applyPermission(getActivity());//跳转到悬浮窗权限界面
return false;
} else {//开启横屏服务
Intent mIntent = new Intent(getActivity(), ChangeOrientationService.class);
mIntent.putExtra("orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getActivity().startService(mIntent);
return true;
}
}
4.悬浮窗相关的类
public class MyWindowManager {
private static final String TAG = "MyWindowManager";
/**
* 小悬浮窗View的参数
*/
private WindowManager.LayoutParams smallWindowParams; /**
* 用于控制在屏幕上添加或移除悬浮窗
*/
private WindowManager mWindowManager; private SensorManager sm;
private Sensor sensor; /**
* 如果WindowManager还未创建,则创建一个新的WindowManager返回。否则返回当前已创建的WindowManager。
*
* @param context 必须为应用程序的Context.
* @return WindowManager的实例,用于控制在屏幕上添加或移除悬浮窗。
*/
private WindowManager getWindowManager(Context context) {
if (mWindowManager == null) {
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
}
return mWindowManager;
} public static boolean checkPermission() {
//6.0 版本之后由于 google 增加了对悬浮窗权限的管理,所以方式就统一了
if (Build.VERSION.SDK_INT < 23) {
if (RomUtils.checkIsMiuiRom()) {
return miuiPermissionCheck(BaseApplication.getInstance());
} else if (RomUtils.checkIsMeizuRom()) {
return meizuPermissionCheck(BaseApplication.getInstance());
} else if (RomUtils.checkIsHuaweiRom()) {
return huaweiPermissionCheck(BaseApplication.getInstance());
} else if (RomUtils.checkIs360Rom()) {
return qikuPermissionCheck(BaseApplication.getInstance());
}
}
return commonROMPermissionCheck(BaseApplication.getInstance());
} private static boolean huaweiPermissionCheck(Context context) {
return HuaweiUtils.checkFloatWindowPermission(context);
} private static boolean miuiPermissionCheck(Context context) {
return MiuiUtils.checkFloatWindowPermission(context);
} private static boolean meizuPermissionCheck(Context context) {
return MeizuUtils.checkFloatWindowPermission(context);
} private static boolean qikuPermissionCheck(Context context) {
return QikuUtils.checkFloatWindowPermission(context);
} private static boolean commonROMPermissionCheck(Context context) {
//最新发现魅族6.0的系统这种方式不好用,天杀的,只有你是奇葩,没办法,单独适配一下
if (RomUtils.checkIsMeizuRom()) {
return meizuPermissionCheck(context);
} else {
Boolean result = true;
if (Build.VERSION.SDK_INT >= 23) {
try {
Class clazz = Settings.class;
Method canDrawOverlays = clazz.getDeclaredMethod("canDrawOverlays", Context.class);
result = (Boolean) canDrawOverlays.invoke(null, context);
} catch (Exception e) {
Log.e(TAG, "commonROMPermissionCheck: " + Log.getStackTraceString(e));
}
}
return result;
}
} public static void applyPermission(Context context) {
if (Build.VERSION.SDK_INT < 23) {
if (RomUtils.checkIsMiuiRom()) {
miuiROMPermissionApply(context);
} else if (RomUtils.checkIsMeizuRom()) {
meizuROMPermissionApply(context);
} else if (RomUtils.checkIsHuaweiRom()) {
huaweiROMPermissionApply(context);
} else if (RomUtils.checkIs360Rom()) {
ROM360PermissionApply(context);
}
}
commonROMPermissionApply(context);
} public interface OnConfirmResult {
void confirmResult(boolean confirm);
} private static void showConfirmDialog(Context context, OnConfirmResult result) {
showConfirmDialog(context, "您的手机没有授予悬浮窗权限,请开启后再试", result);
} private static void showConfirmDialog(Context context, String message, final OnConfirmResult result) {
android.support.v7.app.AlertDialog dialog = new android.support.v7.app.AlertDialog.Builder(context).setCancelable(true).setTitle("")
.setMessage(message)
.setPositiveButton("现在去开启",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirmResult(true);
dialog.dismiss();
}
}).setNegativeButton("暂不开启",
new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
result.confirmResult(false);
dialog.dismiss();
}
}).create();
dialog.show(); /*if (dlg != null && dlg.isShowing()) {
dlg.dismiss();
} dlg = new UpdateDlg(context, false);
dlg.show();
dlg.setContent("", message);
dlg.setButton("暂不开启", "现在去开启");
dlg.setListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
result.confirmResult(true);
dlg.dismiss();
}
});*/ } private static void ROM360PermissionApply(final Context context) {
showConfirmDialog(context, new OnConfirmResult() {
@Override
public void confirmResult(boolean confirm) {
if (confirm) {
QikuUtils.applyPermission(context);
} else {
Log.d(TAG, "ROM:360, user manually refuse OVERLAY_PERMISSION ");
}
}
});
} private static void huaweiROMPermissionApply(final Context context) {
showConfirmDialog(context, new OnConfirmResult() {
@Override
public void confirmResult(boolean confirm) {
if (confirm) {
HuaweiUtils.applyPermission(context);
} else {
Log.d(TAG, "ROM:huawei, user manually refuse OVERLAY_PERMISSION");
}
}
});
} private static void meizuROMPermissionApply(final Context context) {
showConfirmDialog(context, new OnConfirmResult() {
@Override
public void confirmResult(boolean confirm) {
if (confirm) {
MeizuUtils.applyPermission(context);
} else {
Log.d(TAG, "ROM:meizu, user manually refuse OVERLAY_PERMISSION");
}
}
});
} private static void miuiROMPermissionApply(final Context context) {
showConfirmDialog(context, new OnConfirmResult() {
@Override
public void confirmResult(boolean confirm) {
if (confirm) {
MiuiUtils.applyMiuiPermission(context);
} else {
Log.d(TAG, "ROM:miui, user manually refuse OVERLAY_PERMISSION: ");
}
}
});
} /**
* 通用 rom 权限申请
*/
private static void commonROMPermissionApply(final Context context) {
//这里也一样,魅族系统需要单独适配
if (RomUtils.checkIsMeizuRom()) {
meizuROMPermissionApply(context);
} else {
if (Build.VERSION.SDK_INT >= 23) {
showConfirmDialog(context, new OnConfirmResult() {
@Override
public void confirmResult(boolean confirm) {
if (confirm) {
try {
Class clazz = Settings.class;
Field field = clazz.getDeclaredField("ACTION_MANAGE_OVERLAY_PERMISSION"); Intent intent = new Intent(field.get(null).toString());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("package:" + context.getPackageName()));
context.startActivity(intent);
} catch (Exception e) {
Log.d(TAG, "confirmResult: " + Log.getStackTraceString(e));
}
} else {
Log.d(TAG, "user manually refuse OVERLAY_PERMISSION");
//需要做统计效果
}
}
});
}
}
}
}
public class HuaweiUtils {
private static final String TAG = "HuaweiUtils"; /**
* 检测 Huawei 悬浮窗权限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
} /**
* 去华为权限申请页面
*/
public static void applyPermission(Context context) {
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.permissionmanager.ui.MainActivity");//华为权限管理
// ComponentName comp = new ComponentName("com.huawei.systemmanager",
// "com.huawei.permissionmanager.ui.SingleAppActivity");//华为权限管理,跳转到指定app的权限管理位置需要华为接口权限,未解决
ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity");//悬浮窗管理页面
intent.setComponent(comp);
if (RomUtils.getEmuiVersion() == 3.1) {
//emui 3.1 的适配
context.startActivity(intent);
} else {
//emui 3.0 的适配
comp = new ComponentName("com.huawei.systemmanager", "com.huawei.notificationmanager.ui.NotificationManagmentActivity");//悬浮窗管理页面
intent.setComponent(comp);
context.startActivity(intent);
}
} catch (SecurityException e) {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.permissionmanager.ui.MainActivity");//华为权限管理
ComponentName comp = new ComponentName("com.huawei.systemmanager",
"com.huawei.permissionmanager.ui.MainActivity");//华为权限管理,跳转到本app的权限管理页面,这个需要华为接口权限,未解决
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity");//悬浮窗管理页面
intent.setComponent(comp);
context.startActivity(intent);
Log.e(TAG, Log.getStackTraceString(e));
} catch (ActivityNotFoundException e) {
/**
* 手机管家版本较低 HUAWEI SC-UL10
*/
// Toast.makeText(MainActivity.this, "act找不到", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.Android.settings", "com.android.settings.permission.TabItem");//权限管理页面 android4.4
// ComponentName comp = new ComponentName("com.android.settings","com.android.settings.permission.single_app_activity");//此处可跳转到指定app对应的权限管理页面,但是需要相关权限,未解决
intent.setComponent(comp);
context.startActivity(intent);
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
} catch (Exception e) {
//抛出异常时提示信息
Toast.makeText(context, "进入设置页面失败,请手动设置", Toast.LENGTH_LONG).show();
Log.e(TAG, Log.getStackTraceString(e));
}
} @TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
}
}
public class MeizuUtils {
private static final String TAG = "MeizuUtils"; /**
* 检测 meizu 悬浮窗权限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
} /**
* 去魅族权限申请页面
*/
public static void applyPermission(Context context){
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
intent.setClassName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity");
intent.putExtra("packageName", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} @TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
}
}
public class MiuiUtils {
private static final String TAG = "MiuiUtils"; /**
* 获取小米 rom 版本号,获取失败返回 -1
*
* @return miui rom version code, if fail , return -1
*/
public static int getMiuiVersion() {
String version = RomUtils.getSystemProperty("ro.miui.ui.version.name");
if (version != null) {
try {
return Integer.parseInt(version.substring(1));
} catch (Exception e) {
Log.e(TAG, "get miui version code error, version : " + version);
Log.e(TAG, Log.getStackTraceString(e));
}
}
return -1;
} /**
* 检测 miui 悬浮窗权限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT; if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
} else {
// if ((context.getApplicationInfo().flags & 1 << 27) == 1) {
// return true;
// } else {
// return false;
// }
return true;
}
} @TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
} /**
* 小米 ROM 权限申请
*/
public static void applyMiuiPermission(Context context) {
int versionCode = getMiuiVersion();
if (versionCode == 5) {
goToMiuiPermissionActivity_V5(context);
} else if (versionCode == 6) {
goToMiuiPermissionActivity_V6(context);
} else if (versionCode == 7) {
goToMiuiPermissionActivity_V7(context);
} else if (versionCode == 8) {
goToMiuiPermissionActivity_V8(context);
} else {
Log.e(TAG, "this is a special MIUI rom version, its version code " + versionCode);
}
} private static boolean isIntentAvailable(Intent intent, Context context) {
if (intent == null) {
return false;
}
return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
} /**
* 小米 V5 版本 ROM权限申请
*/
public static void goToMiuiPermissionActivity_V5(Context context) {
Intent intent = null;
String packageName = context.getPackageName();
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "intent is not available!");
} //设置页面在应用详情页面
// Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
// PackageInfo pInfo = null;
// try {
// pInfo = context.getPackageManager().getPackageInfo
// (HostInterfaceManager.getHostInterface().getApp().getPackageName(), 0);
// } catch (PackageManager.NameNotFoundException e) {
// AVLogUtils.e(TAG, e.getMessage());
// }
// intent.setClassName("com.android.settings", "com.miui.securitycenter.permission.AppPermissionsEditor");
// intent.putExtra("extra_package_uid", pInfo.applicationInfo.uid);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// if (isIntentAvailable(intent, context)) {
// context.startActivity(intent);
// } else {
// AVLogUtils.e(TAG, "Intent is not available!");
// }
} /**
* 小米 V6 版本 ROM权限申请
*/
public static void goToMiuiPermissionActivity_V6(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
} /**
* 小米 V7 版本 ROM权限申请
*/
public static void goToMiuiPermissionActivity_V7(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
} /**
* 小米 V8 版本 ROM权限申请
*/
public static void goToMiuiPermissionActivity_V8(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
// intent.setPackage("com.miui.securitycenter");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setPackage("com.miui.securitycenter");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
}
}
}
public class QikuUtils {
private static final String TAG = "QikuUtils"; /**
* 检测 360 悬浮窗权限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
} @TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e("", "Below API 19 cannot invoke!");
}
return false;
} /**
* 去360权限申请页面
*/
public static void applyPermission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.Settings$OverlaySettingsActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
intent.setClassName("com.qihoo360.mobilesafe", "com.qihoo360.mobilesafe.ui.index.appEnterActivity");
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "can't open permission page with particular name, please use " +
"\"adb shell dumpsys activity\" command and tell me the name of the float window permission page");
}
}
} private static boolean isIntentAvailable(Intent intent, Context context) {
if (intent == null) {
return false;
}
return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
}
}
public class RomUtils {
private static final String TAG = "RomUtils"; /**
* 获取 emui 版本号
* @return
*/
public static double getEmuiVersion() {
try {
String emuiVersion = getSystemProperty("ro.build.version.emui");
String version = emuiVersion.substring(emuiVersion.indexOf("_") + 1);
return Double.parseDouble(version);
} catch (Exception e) {
e.printStackTrace();
}
return 4.0;
} /**
* 获取小米 rom 版本号,获取失败返回 -1
*
* @return miui rom version code, if fail , return -1
*/
public static int getMiuiVersion() {
String version = getSystemProperty("ro.miui.ui.version.name");
if (version != null) {
try {
return Integer.parseInt(version.substring(1));
} catch (Exception e) {
Log.e(TAG, "get miui version code error, version : " + version);
}
}
return -1;
} public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
Log.e(TAG, "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
public static boolean checkIsHuaweiRom() {
return Build.MANUFACTURER.contains("HUAWEI");
} /**
* check if is miui ROM
*/
public static boolean checkIsMiuiRom() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
} public static boolean checkIsMeizuRom() {
//return Build.MANUFACTURER.contains("Meizu");
String meizuFlymeOSFlag = getSystemProperty("ro.build.display.id");
if (TextUtils.isEmpty(meizuFlymeOSFlag)){
return false;
}else if (meizuFlymeOSFlag.contains("flyme") || meizuFlymeOSFlag.toLowerCase().contains("flyme")){
return true;
}else {
return false;
}
} public static boolean checkIs360Rom() {
return Build.MANUFACTURER.contains("QiKU");
}
}
android设置系统横屏方案的更多相关文章
- Android设置系统开机自己主动永不休眠
android4.2系统增永不休眠同一时候隐藏休眠选项 1. android\frameworks\base\packages\SettingsProvider\res\values\defaults ...
- android设置系统模式
android 静音与振动1,设置静音和振动静音和振动都属于来电后的动作.所以在设置静音和振动时都只是设置一些标识,并往数据库写入相应标识. 文件:packages/apps/settings/src ...
- android设置系统默认开机时间
1.设置RTC时间,该时间是如果RCT时钟断电以后使用的默认时间 Android L之前: \alps\mediatek\custom\[project]\preloader\ inc\cust_rt ...
- android 设置布局横屏竖屏
只要在AndroidManifest.xml里面配置一下就可以了.在AndroidManifest.xml的activity(需要禁止转向的activity)配置中加入android:screenOr ...
- android 设置系统屏幕亮度
/** * 获得当前屏幕亮度的模式 * SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度 * SCREEN_BRIGHTNESS_MODE_MANUAL=0 为 ...
- Android 通过应用程序来设置系统的日期和时间中的
Android 通过应用程序来设置系统的日期和时间中的 android 2.3 android 4.0 测试可行,刚需ROOT权限. import java.io.DataOutputStream; ...
- Android开发技巧——设置系统状态栏颜色
开门见山,先来三张效果图: 然后我们再来讲如何实现以及如何快速地实现. 如何实现 实现设置系统状态栏颜色需要至少在Android 4.4.2(API 19)以上.这是因为,在这个版本以下,没有任何的A ...
- [Android] 字体使用dp单位避免设置系统字体大小对排版的影响
[Android] 字体使用dp单位避免设置系统字体大小对排版的影响 以魄族mx3为例,在设置->显示->字体大小中能够选择字号大小例如以下图: 图1. 魄族mx3 会导致软件在有固定定高 ...
- Android : 反射机制获取或设置系统属性(SystemProperties)【转】
本文转载自:https://blog.csdn.net/wei_lei/article/details/70312512 Android.os.SystemProperties 提供了获取和设置系统属 ...
随机推荐
- C++中的const关键字学习笔记
一.const引用 1. 例子一 #include <iostream> using namespace std; class sp { public: sp() {cout<< ...
- sqler sql 转rest api redis 接口使用
sqler 支持redis 协议,我们可以用过redis client 连接sqler,他会将宏住转换为redis command 实现上看源码我们发现是基于一个开源的redis 协议的golang ...
- Yuan先生的博客网址
1 Web应用 https://www.cnblogs.com/yuanchenqi/articles/8869302.html 2 http协议 https://www.cnblogs.com/y ...
- taro 知识点
taro 的包: 包名 说明 @tarojs/redux Redux for Taro @tarojs/redux-h5 Forked react-redux for taro @tarojs/plu ...
- openstack 开启 spice远程连接
openstack 默认开的远程控制是novnc 这里是用kolla初建的openstack nova_console vi /etc/kolla/globals.yml ... # Valid op ...
- 安装mysql时包冲突解决方法
报错信息如下: 解决办法: 在卸载代码上加上不检查关联信息即可(rpm -ev mysql-libs-5.1.73-7.el6.x86_64 --nodeps) 检查服务器是否还有mysql安装包:r ...
- php调用c#的dll(转)
这几天,一直在做DES ecb模式的加解密,刚用.net实现了加解密,完了由于需要又要转型成PHP代码,费了九牛二虎之力单独用PHP没能实现,结构看到一篇php直接调用c#里生成的.dll文件的方法, ...
- RedHat6.5安装kafka集群
版本号: Redhat6.5 JDK1.8 zookeeper-3.4.6 kafka_2.11-0.8.2.1 1.软件环境 1.3台RedHat机器,master.slave1. ...
- tomcat端口号被占用的问题
错误原因:8080端口被其他的应用占用! 在网上查了下解决方案,有些说在任务管理窗口关闭javaw.exe,有些说shutdown一下tomcat,亲测在某些场合下可用. 下面是摘自其它博客园里文章的 ...
- elasticsearch 聚合函数 max double精度损失bug
测试样例数据{ "size" : 0, "query" : { "bool" : { "must" : { " ...