Oreo(API 26)-drawOverlay +覆写状态栏 [英] Oreo (API 26) - drawOverlay + draw over status bar

查看:208
本文介绍了Oreo(API 26)-drawOverlay +覆写状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android oreo中,我不能再使用WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,而必须使用WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY.缺点是该模式不会覆盖状态栏.

无论如何,是否有实现旧行为并能够覆盖状态栏的功能?我有一个侧边栏应用程序,并且直到现在,我还允许用户在屏幕上方也有触发区域,现在该区域不再起作用,因为状态栏现在与上方的可触摸区域重叠...

我对任何解决方案都感兴趣,即使它仅适用于某些设备,例如有根设备也是如此...我认为对于此问题没有正常的解决方案,因为android系统已不再允许该解决方案,如docs( https://developer.android. com/about/versions/oreo/android-8.0-changes.html#o-apps ).尽管如此,这并不一定意味着没有替代解决方案...

解决方案

文档说,该标志对于非系统应用程序已弃用.您是否尝试过将该应用程序制作为系统应用程序?

对于非系统应用,此常量在API级别26中已弃用.

以下是ES File Explorer的使用方法:

Configure ES File Explorer by doing the following steps:
    Launch ES File Explorer.
    Select Menu and choose Settings.
    Under Settings, enable the options for Up to root and Root Explorer. A message will appear, requiring you to confirm your action. You will also need to confirm Superuser access.
    Enable Mount File System.
    Go back to the app’s main menu.
Get a copy of the APK (Android Package) of the app that you want to save as a system file by doing the following steps (skip to step 3 if you already have the app’s APK file):
    Install an app from the Google Play Store. For this guide, we will be using the app BioRhythms as an example.
    Launch ES File Explorer and navigate to /data/app.
    Locate the APK file that you want to install as a system app. If you don’t know the APK’s filename, simply go to the Google Play Store link of your chosen app. View the link and take note of the words after ?id=. This will be your APK’s filename. For instance, the BioRhythms app link is https://play.google.com/store/apps/details?id=app.biorhythms. The BioRhythms’ APK is app.biorhythms-1.apk.
Create a backup of the chosen APK by copying it to the phone’s SD Card.
After creating a backup, long tap on the APK file and a menu will appear. Choose Cut. A blue arrow will appear at the bottom of the screen.
Go back to the main menu and navigate to /system/app/.
Drag the little arrow at the bottom of the screen. It will bring up the icon of the APK file.
Tap the APK file and it will be transferred to /system/app/.
Find the APK file in /system/app/. Press and hold it and a menu will appear.
Select Properties on the menu. The dialog properties will show up.
Tap Change and it will show the permissions dialog box.
Check the boxes for the following permissions in the dialog box:
    User: Read and Write
    Group: Read
    Other: Read
Select OK once the required settings have been made.
Reboot your device.

In android oreo, I can't use WindowManager.LayoutParams.TYPE_SYSTEM_ERROR anymore and must use WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY instead. The drawback is, that this mode does not draw over the statusbar.

Is there anyway to achieve the old behaviour and be able to draw over the statusbar as well? I've a sidebar app and until now, I allowed the user to have trigger areas on top of the screen as well, which does not work anymore now, because the status bar is overlapping the touchable region on top now...

I'm interested in ANY solution, even if it's only for some devices, like rooted devices for example... As I think there is not normal solution for this problem because the android system does not allow this anymore as stated in the docs (https://developer.android.com/about/versions/oreo/android-8.0-changes.html#o-apps). Still, this does not necessary mean that there is no alternative solution...

解决方案

The docs says that the flag is deprecated for non-system apps. Have you tried making the app a system app?

This constant was deprecated in API level 26. for non-system apps.

Here is how with ES File Explorer:

Configure ES File Explorer by doing the following steps:
    Launch ES File Explorer.
    Select Menu and choose Settings.
    Under Settings, enable the options for Up to root and Root Explorer. A message will appear, requiring you to confirm your action. You will also need to confirm Superuser access.
    Enable Mount File System.
    Go back to the app’s main menu.
Get a copy of the APK (Android Package) of the app that you want to save as a system file by doing the following steps (skip to step 3 if you already have the app’s APK file):
    Install an app from the Google Play Store. For this guide, we will be using the app BioRhythms as an example.
    Launch ES File Explorer and navigate to /data/app.
    Locate the APK file that you want to install as a system app. If you don’t know the APK’s filename, simply go to the Google Play Store link of your chosen app. View the link and take note of the words after "?id=". This will be your APK’s filename. For instance, the BioRhythms app link is https://play.google.com/store/apps/details?id=app.biorhythms. The BioRhythms’ APK is app.biorhythms-1.apk.
Create a backup of the chosen APK by copying it to the phone’s SD Card.
After creating a backup, long tap on the APK file and a menu will appear. Choose Cut. A blue arrow will appear at the bottom of the screen.
Go back to the main menu and navigate to /system/app/.
Drag the little arrow at the bottom of the screen. It will bring up the icon of the APK file.
Tap the APK file and it will be transferred to /system/app/.
Find the APK file in /system/app/. Press and hold it and a menu will appear.
Select Properties on the menu. The dialog properties will show up.
Tap Change and it will show the permissions dialog box.
Check the boxes for the following permissions in the dialog box:
    User: Read and Write
    Group: Read
    Other: Read
Select OK once the required settings have been made.
Reboot your device.

这篇关于Oreo(API 26)-drawOverlay +覆写状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆