屏幕叠加检测Android

时间:2017-12-23 13:21:19

标签: android

我发现在Motog3 marshmallow mobile的点击权限时检测到以下问题的屏幕覆盖。

我发现很多地方的互联网搜索解决方案,您可以查看以下内容:

  1. 删除esfile explorer

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

  3. Screen overlay detected blocks Android permissions

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

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

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

  7. https://github.com/MohammadAdib/Roundr/issues/10

  8. Android marshmallow : Galaxy Note 4 Screen Overlay Detected
  9. 等。更多。

    如果我没有在下面拨打电话,那就没问题了。

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

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

    随时可以询问我共享某些代码的任何信息或代码。

    清单:

    <?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;
        }
    

    提前致谢,寻求完美解决方案。

1 个答案:

答案 0 :(得分:1)

最后我得到了上面检测到屏幕覆盖问题的解决方案 通过删除以下用于测试应用程序内存使用情况的代码:

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();

感谢大家的支持!