{"id":13492677,"url":"https://github.com/datanapps/AndroidUtility","last_synced_at":"2025-03-28T10:32:46.369Z","repository":{"id":217435450,"uuid":"165179466","full_name":"datanapps/AndroidUtility","owner":"datanapps","description":"An android utility library for use log, snackbar, dateUtils, Collection utils and many more","archived":false,"fork":false,"pushed_at":"2021-08-03T04:29:46.000Z","size":374,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-01T19:44:15.069Z","etag":null,"topics":["android","android-app","android-application","android-lib","android-library","exception-handling","fileutils","kotlin","kotlin-android","kotlin-library","kotlin-utility","logcat","sharedpreferences","snackbar","toast","utility-library"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datanapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-11T04:31:36.000Z","updated_at":"2024-05-20T02:11:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"111363e5-d6c1-41ef-9ee4-245991386967","html_url":"https://github.com/datanapps/AndroidUtility","commit_stats":null,"previous_names":["datanapps/androidutility"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datanapps%2FAndroidUtility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datanapps%2FAndroidUtility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datanapps%2FAndroidUtility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datanapps%2FAndroidUtility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datanapps","download_url":"https://codeload.github.com/datanapps/AndroidUtility/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222369834,"owners_count":16973287,"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","android-app","android-application","android-lib","android-library","exception-handling","fileutils","kotlin","kotlin-android","kotlin-library","kotlin-utility","logcat","sharedpreferences","snackbar","toast","utility-library"],"created_at":"2024-07-31T19:01:08.177Z","updated_at":"2024-10-31T06:31:27.616Z","avatar_url":"https://github.com/datanapps.png","language":"Java","readme":"# AndroidUtility (Kotlin extension) \n\n**1. StringUtils**\n\n**2. ContextUtils**\n\n\n---------------------------------------\n\n# AndroidUtility (Java) \n\n**This library contain:**\n\n**1. Logcat**\n\n**2. Snackbar**\n\n**3. Toast**\n\n**4. CollectionUtils**\n\n**5. AppUtils**\n\n**6. DateUtils**\n\n**7. StringUtils**\n\n**8. FileUtils**\n\n**9. Shared Preference**\n\n**10. ExceptionHandler**\n\n**11. Device Detail**\n\n**12. Internet Connection Details**\n\n**13. Battery Details**\n\n\n# How to integrate:\n\n1. Download and extract folder \n2. Copy utils folder in your folder app-\u003esrc-\u003emain-\u003ejava-\u003eyourpackagename-\u003e \u003cutils\u003e\n3. Now ready to use some basics of android applications\n\n=============================================================================\n# How to integrate this utility in your application:\n=============================================================================\n# 1. Logcat\n\nFor debug :\n\nDNALog.d(\"this is debug message\");\n\nFor error :\n\nDNALog.e(\"this is debug message\");\n\nFor info :\n\nDNALog.i(\"this is debug message\");\n\nFor verbose :\n\nDNALog.v(\"this is debug message\");\n\n\n#### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. This log will work only in debug application.\n3. It will give you more information then simple log.\n\n=============================================================================\n\n# 2. Snackbar\n\n\nDNASnackBar.show( this,\" this is test message\");\n\n\n#### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. A single class have multiple function.\n3. Handling null pointer\n4. if given activity is is null or context then no crash and it will show toast.\n\n=============================================================================\n\n# 3. Toast\n// call method\nDNAToast.show(this, \" this is test message\");\n\n#### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. A single class have multiple function.\n3. Handling null pointer\n\n=============================================================================\n\n# 4. CollectionUtils\n\n List\u003cT\u003e mediaList = new ArrayList();\n \n \n        if (DNACollectionUtils.isEmpty(mediaList)) {\n            // do your stuff \n        }\n\n        if (DNACollectionUtils.isNotEmpty(mediaList)) {\n            // do your stuff \n        }\n        \n        if (DNACollectionUtils.isNull(mediaList)) {\n            // do your stuff \n        }\n        \n        if (DNACollectionUtils.size(mediaList)) {\n            // do your stuff \n        }\n        \n   #### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It will work for all collections like list, arraylist, hashmap etc\n3. Handling null pointer in side method\n     \n     \n=============================================================================\n\n# 5. AppUtils\n\n// provide all details about application at one place.\n\nDNALog.d(\"App Id\"+ DNAAppUtils.getApplicationId());\n\nDNALog.d(\"App Id\"+ DNAAppUtils.getApplicationPackageName());\n\nDNALog.d(\"Version Code : \"+ DNAAppUtils.getAppVersionCode());\n\nDNALog.d(\"Version Name : \"+ DNAAppUtils.getAppVersionName());\n\nDNALog.d(\"Build Type: \"+ DNAAppUtils.getBuildType());\n\nDNALog.d(\"This is bug build : \"+ DNAAppUtils.isBuildType());\n\n\n\n #### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It will provide all application information at same place.\n3. Easy to integrate and easy to use and provide a support for application\n        \n=============================================================================\n\n# 6. StringUtils\n\nString stringList;\n \n \n        if (DNAStringUtils.isEmpty(stringList)) {\n            // do your stuff \n        }\n\n        if (DNAStringUtils.isNotEmpty(stringList)) {\n            // do your stuff \n        }\n        \n        if (DNAStringUtils.isNull(stringList)) {\n            // do your stuff \n        }\n        \n        if (DNAStringUtils.length(stringList)) {\n            // do your stuff \n        }\n        \n   #### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It provide SOME value like EMPTY, NEW LINE, SPACE. NA etc.\n3. its checking for NULL and empty both\n     \n\n=============================================================================\n\n# 7. SharedPreference\n\nIn Application file just initialise Preference at once in OnCreate .\n\n      public class UtilityApplication extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n\n\n        // java\n        DNASharedPreferenceUtils.init(this);\n        //or\n        //pass custom parameter\n        DNASharedPreferenceUtils.init(this, \"preference_name\", Context.MODE_PRIVATE);\n\n\n\n        //kotlin\n        datanapps.androidutility.utils.kotlin.DNASharedPreferenceUtils.INSTANCE.init(this);\n        //or\n        //pass custom parameter\n        datanapps.androidutility.utils.kotlin.DNASharedPreferenceUtils.INSTANCE.init(this, \"preference_name\", Context.MODE_PRIVATE);\n\n\n    }\n}\n\n\nTo use in Application:\n\n\n        // for save value\n        DNASharedPreferenceUtils.saveString(\"key\", \"this is my value\");\n\n        //get value\n        DNALog.d(\" value :  \"+ DNASharedPreferenceUtils.getString(\"key\"));\n\n #### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It provide all method to save like STRING, FLOAT, INTEGER, LONG, BOOLEAN.\n3. Easy to integrate and easy to use and provide.\n4. All above repo class is tested.\n\n\n=============================================================================\n\n# 8. FileUtils\n\n\nThis file can use to \n\n1. Create File\n\nFile file = DNAFileUtils.createFile(Environment.getDataDirectory(), DNAFileUtils.PNG);\n\n2. To Check existence of file:\n\nboolean isExist = DNAFileUtils.isFileExist(file);\n\n3.To GetFileSize :\n\nint size = DNAFileUtils.getFileSize(file);\n\n#### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It provide all method related file : CREATE, FILE SIZE, EXISTIENCE OF FILE, \n3. Easy to integrate and easy to use and provide.\n\n\n=============================================================================\n\n# 9. ExceptionHandler\nEasy to handle exception with one line and manually added crash in Crashlytics\n\nJAVA/KOTLIN : \n\n     private void login() {\n\n        try {\n           // do your login stuff\n        } catch (Exception e) {\n            DNAExceptionHandler.handleException(e);\n            // handle your exception here!\n        }\n    }\n    \n   #### Benifits:\n1. It provide support in JAVA as well as KOTLIN\n2. It provide to catch all try catch flow in application and manually you can send all exception to your tracker like crashlytics. \n3. Easy to integrate and easy to use and provide.\n\n\n=============================================================================\n\n# 10. Device Detail\n\n#### JAVA/KOTLIN : \n\n        Log.i(\"DNA\", \"SERIAL: \" + DNADeviceUtils.getSerial());\n        Log.i(\"DNA\",\"MODEL: \" + DNADeviceUtils.getModel());\n        Log.i(\"DNA\",\"ID: \" + DNADeviceUtils.getDeviceId());\n        Log.i(\"DNA\",\"Manufacture: \" + DNADeviceUtils.getManufacturer());\n        Log.i(\"DNA\",\"brand: \" + DNADeviceUtils.getBrand());\n        Log.i(\"DNA\",\"type: \" + DNADeviceUtils.getType());\n        Log.i(\"DNA\",\"user: \" + DNADeviceUtils.getUser());\n        Log.i(\"DNA\",\"BASE: \" + DNADeviceUtils.getBaseVersionCode());\n        Log.i(\"DNA\",\"INCREMENTAL \" + DNADeviceUtils.getVersionIncremental());\n        Log.i(\"DNA\",\"SDK  \" + DNADeviceUtils.getSDKVersion());\n        Log.i(\"DNA\",\"BOARD: \" + DNADeviceUtils.getBoard());\n        Log.i(\"DNA\",\"HOST \" + DNADeviceUtils.getDeviceHost());\n        Log.i(\"DNA\",\"FINGERPRINT: \"+DNADeviceUtils.getDeviceFingerprint());\n        Log.i(\"DNA\",\"Version Code: \" + DNADeviceUtils.getVersionRelease());\n    \n    \n   #### Output:\n    \n    \n     SERIAL: WCR7N18613005916\n     MODEL: CLT-L29\n     ID: HUAWEICLT-L29\n     Manufacture: HUAWEI\n     brand: HUAWEI\n     type: user\n     user: test\n     BASE: 1\n     INCREMENTAL 155(C636)\n     SDK  27\n     BOARD: CLT\n     HOST szvphicpra02075\n     FINGERPRINT: HUAWEI/CLT-L29/HWCLT:8.1.0/HUAWEICLT-L29/155(C636):user/release-keys\n     Version Code: 8.1.0\n  \n    =============================================================================\n\n# 11. Internet Details\n    \n    #### JAVA/KOTLIN : \n    \n     Log.i(\"DNA\", \"connected with internet : \" + DNANetworkUtils.isInternetConnected(this));\n     \n     =============================================================================\n\n# 12. Battery Details\n    \n    #### JAVA/KOTLIN : \n    \n    public class BatteryActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        registerReceiver(this.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));\n\n    }\n\n\n    private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {\n        @Override\n        public void onReceive(Context c, Intent intent) {\n            int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);\n            int voltage = intent.getIntExtra(\"voltage\", 0);\n            int temperature = intent.getIntExtra(\"temperature\", 0);\n\n            int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);\n            boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||\n                    status == BatteryManager.BATTERY_STATUS_FULL;\n\n            int chargePlug = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);\n            boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;\n            boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;\n\n            DNALog.d(\"Is Charging :\" + String.valueOf(isCharging) );\n            DNALog.d(\"Charging Type  USB:\" + String.valueOf(usbCharge) );\n            DNALog.d(\"Charging Type  AC:\" + String.valueOf(acCharge) );\n            DNALog.d(\"Battery Status: \" + String.valueOf(status) + \"%\");\n            DNALog.d(\"Battery Level: \" + String.valueOf(level) + \"%\");\n            DNALog.d(\"Battery Voltage: \" + String.valueOf(voltage));\n            double temps = (double)temperature / 10;\n            DNALog.d(\"Battery Temperature: \" + String.valueOf(temps));\n        }\n       };\n     }\n\n   #### Output:\n\n     Charging Type  USB:true\n      Charging Type  AC:false\n      Battery Status: 5%\n      Battery Level: 100%\n      Battery Voltage: 4265\n      Battery Temperature: 25.2\n      Is Charging :true\n      Charging Type  USB:true\n      Charging Type  AC:false\n      Battery Status: 5%\n      Battery Level: 100%\n      Battery Voltage: 4186\n      Battery Temperature: 25.8\n\n\n #### If you think this library is useful, please press the star button at the top.\n \n \u003cimg src=\"https://datanapps.com/public/dnarestapi/githubstar.png\" height=\"100\" width=\"200\"\u003e\n\n\n#### OR \n \n \u003cimg src=\"https://datanapps.com/public/dnarestapi/naughty_smile.jpg\" height=\"200\" width=\"300\"\u003e\n \n \n [![See](https://datanapps.com/public/dnarestapi/buy/buy_coffee2.png)](https://www.paypal.me/datanappspaynow)\n\n  ### License\n\nCopyright [2021] [datanapps]\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   http://www.apache.org/licenses/LICENSE-2.0\n","funding_links":["https://www.paypal.me/datanappspaynow"],"categories":["Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatanapps%2FAndroidUtility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatanapps%2FAndroidUtility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatanapps%2FAndroidUtility/lists"}