{"id":27879180,"url":"https://github.com/androidbroadcast/strictmodecompat","last_synced_at":"2025-05-05T03:19:05.679Z","repository":{"id":37556386,"uuid":"87624439","full_name":"androidbroadcast/StrictModeCompat","owner":"androidbroadcast","description":"Safety call StrctiMode API methods from newer Android SDK on old versions","archived":false,"fork":false,"pushed_at":"2022-04-11T18:10:32.000Z","size":464,"stargazers_count":88,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T03:18:58.124Z","etag":null,"topics":["android","compat","kotlin","kotlin-android","strict-mode"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/androidbroadcast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-08T09:58:25.000Z","updated_at":"2025-04-21T13:04:16.000Z","dependencies_parsed_at":"2022-09-26T21:41:00.311Z","dependency_job_id":null,"html_url":"https://github.com/androidbroadcast/StrictModeCompat","commit_stats":null,"previous_names":["kirich1409/strictmodecompat"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidbroadcast%2FStrictModeCompat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidbroadcast%2FStrictModeCompat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidbroadcast%2FStrictModeCompat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/androidbroadcast%2FStrictModeCompat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/androidbroadcast","download_url":"https://codeload.github.com/androidbroadcast/StrictModeCompat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429949,"owners_count":21746574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","compat","kotlin","kotlin-android","strict-mode"],"created_at":"2025-05-05T03:19:05.095Z","updated_at":"2025-05-05T03:19:05.650Z","avatar_url":"https://github.com/androidbroadcast.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20StrictMode%20Compat-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5655)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.kirich1409/strict-mode-compat/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.kirich1409/strict-mode-compat)\n\nAndroid StrictMode Compat\n=========================\n\nWrapper of [StrictMode API](https://developer.android.com/reference/android/os/StrictMode.html) that can be safely called on any version of Android.\nYou must apply version of library for you project base on compileSdkVersion:\n\n```groovy\nandroid {\n    compileSdkVersion 30 // 30 is required minimum\n}\n\ndependencies {    \n    implementation \"com.github.kirich1409:strict-mode-compat:30.2.0\"\n\n    // Kotlin Extensions\n    implementation \"com.github.kirich1409:strict-mode-compat-ktx:30.2.0\"\n}\n```\n\nSample\n------\n\n###### build.gradle ######\n```groovy\nandroid {\n    buildTypes {\n        debug {\n            buildConfigField 'boolean', 'DEVELOPER_MODE', 'true'\n        }\n        \n        release {\n            buildConfigField 'boolean', 'DEVELOPER_MODE', 'false'\n        }\n    }\n}\n```\n\n###### SampleApplication.java ######\n```java\npublic class SampleApplication extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        if (BuildConfig.DEVELOPER_MODE) {\n            StrictMode.ThreadPolicy threadPolicy = new StrictModeCompat.ThreadPolicy.Builder()\n                        .detectResourceMismatches()\n                        .detectCustomSlowCalls()\n                        .detectUnbufferedIo()  // Available only on Android 8.0+\n                        .penaltyLog()\n                        .build();\n\n            StrictMode.VmPolicy vmPolicy = new StrictModeCompat.VmPolicy.Builder()\n                    .detectFileUriExposure()\n                    .detectLeakedRegistrationObjects()\n                    .detectCleartextNetwork()\n                    .detectUntaggedSockets() // Available only on Android 8.0+\n                    .detectContentUriWithoutPermission()  // Available only on Android 8.0+\n                    .penaltyLog()\n                    .build();\n\n            StrictModeCompat.setPolicies(threadPolicy, vmPolicy);\n        }\n    }\n}\n```\n\nOr you can use Kotlin extension and configure StrictModeCompat via DSL\n###### SampleApplication.kt ######\n```kotlin\nclass SampleApplicationKt : Application() {\n\n    override fun onCreate() {\n        super.onCreate()\n        initStrictMode(enable = BuildConfig.DEVELOPER_MODE, enableDefaults = false) {\n            threadPolicy {\n                resourceMismatches = true\n                customSlowCalls = true\n                unbufferedIo = true\n\n                penalty {\n                    log = true\n                }\n            }\n\n            vmPolicy {\n                fileUriExposure = true\n                leakedRegistrationObjects = true\n                cleartextNetwork = true\n                cleartextNetwork = true\n                untaggedSockets = true\n                contentUriWithoutPermission = true\n\n                penalty {\n                    log = true\n                }\n            }\n        }\n    }\n}\n```\n\nLicense\n-------\n\n    Copyright 2017-2021 Kirill Rozov\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroidbroadcast%2Fstrictmodecompat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandroidbroadcast%2Fstrictmodecompat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandroidbroadcast%2Fstrictmodecompat/lists"}