屏幕覆盖层检测到Android



我在单击" Motog3 Marshmallow Mobile"中的单击权限时发现了以下屏幕覆盖的问题。

我在任何地方都通过Internet搜索找到了许多解决方案,您可以在下面检查:

  1. 删除Esfile Explorer

  2. https://www.youtube.com/watch?v=qhidevtdryi

  3. 屏幕叠加层检测到的块Android权限

  4. https://android.stackexchange.com/questions/148260/screen-overlay-detected-what-what-is-the-problem

  5. https://forums.androidcentral.com/android-6-0-marshmallow/682802-screen-overlay-detected-what what can-i-do.html

  6. https://www.howtogeek.com/271519/how-to-fix-the-the-screen-overlay-detected-eror-on-on-android/

  7. https://github.com/mohammadadib/roundr/issues/10

  8. Android棉花糖:Galaxy Note 4检测到的屏幕覆盖

等。更多。

如果我不在下面调用权限,那就没问题。

因此,如果有人想提供最佳解决方案,请分享。

请在提及重复之前,我想要适当的解决方案。

随时询问我也共享一些代码的任何信息或代码。

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.psm">
<!---->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/logo"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/MyMaterialTheme">
        <activity android:name=".MainActivity"
            android:screenOrientation="portrait">
        </activity>
        <activity android:name=".SplashScreen"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.nippon.registration.Registration"
           ></activity>
    </application>
</manifest>

MainActivity.java中的权限代码

checkAndRequestPermissions(); //called in oncreate() of activity

   private boolean checkAndRequestPermissions() {
        try {
            int permissionWriteEXTERNALSTORAGE = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
            int PermissionCamera = ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA);

            List<String> listPermissionsNeeded = new ArrayList<>();
            if (permissionWriteEXTERNALSTORAGE != PackageManager.PERMISSION_GRANTED) {
                listPermissionsNeeded.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
            }
            if (PermissionCamera != PackageManager.PERMISSION_GRANTED) {
                listPermissionsNeeded.add(android.Manifest.permission.CAMERA);
            }
            if (!listPermissionsNeeded.isEmpty()) {
                ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), 1);
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

预先感谢您的完美解决方案。

最后,我解决了上述屏幕覆盖的问题的解决方案通过删除以下我正在使用的代码,用于测试应用程序中的内存使用量:

final Runtime runtime = Runtime.getRuntime();
        final long usedMemInMB=(runtime.totalMemory() - runtime.freeMemory()) / 1048576L;
        final long maxHeapSizeInMB=runtime.maxMemory() / 1048576L;
        final long availHeapSizeInMB = maxHeapSizeInMB - usedMemInMB;
        Toast.makeText(getApplicationContext(),String.valueOf(usedMemInMB+"  "+ maxHeapSizeInMB+" "+ availHeapSizeInMB), Toast.LENGTH_LONG).show();

感谢大家的支持!

最新更新