This library is a set of simple wrapper classes that are aimed to help you easily access android device information.

Overview

SysInfo

Simple, single class wrapper to get device information from an android device.

This library provides an easy way to access all the device information without having to deal with all the boilerplate stuff going on inside.

Library also provides option to ask permissions for Marshmellow devices!

How to integrate the library in your app?

Gradle Dependecy
dependencies {
        implementation 'com.an.deviceinfo:deviceinfo:0.1.5'
}

Maven Dependecy

<dependency>
  <groupId>com.an.deviceinfo</groupId>
  <artifactId>deviceinfo</artifactId>
  <version>0.1.5</version>
  <type>pom</type>
</dependency>

Downloads

You can download the aar file from the release folder in this project.
In order to import a .aar library:
1) Go to File>New>New Module
2) Select "Import .JAR/.AAR Package" and click next.
3) Enter the path to .aar file and click finish.
4) Go to File>Project Settings (Ctrl+Shift+Alt+S).
5) Under "Modules," in left menu, select "app."
6) Go to "Dependencies tab.
7) Click the green "+" in the upper right corner.
8) Select "Module Dependency"
9) Select the new module from the list.

Usage

For easy use, I have split up all the device information by the following:
1. Location
2. Ads
3. App
4. Battery
5. Device
6. Memory
7. Network
8. User Installed Apps
9. User Contacts

Location

val locationInfo = LocationInfo(this)
val location: DeviceLocation = locationInfo.location
Value Function Name Returns
Latitude getLatitude() Double
Longitude getLongitude() Double
Address Line 1 getAddressLine1() String
City getCity() String
State getState() String
CountryCode getCountryCode() String
Postal Code getPostalCode() String

Ads

No Google play services needed!
 val ad = AdInfo(this)
        ad.getAndroidAdId(object:AdInfo.AdIdCallback{
            override fun onResponse(context: Context, ad: Ad) {
                TODO("Not yet implemented")
            }

            override fun onError(context: Context, message: String) {
                TODO("Not yet implemented")
            }
        })
Value Function Name Returns
AdvertisingId getAdvertisingId() String
Can Track ads isAdDoNotTrack() boolean

App

val app = App(this)
Value Function Name Returns
App Name getAppName() String
Package Name getPackageName() String
Activity Name getActivityName() String
App Version Name getAppVersionName() String
App Version Code getAppVersionCode() Integer

Battery

val battery = Battery(this)
Value Function Name Returns
Battery Percent getBatteryPercent() int
Is Phone Charging isPhoneCharging() boolean
Battery Health getBatteryHealth() String
Battery Technology getBatteryTechnology() String
Battery Temperature getBatteryTemperature() float
Battery Voltage getBatteryVoltage() int
Charging Source getChargingSource() String
Is Battery Present isBatteryPresent() boolean

Device

val device = Device(this)
Value Function Name Returns
Release Build Version getReleaseBuildVersion() String
Build Version Code Name getBuildVersionCodeName() String
Manufacturer getManufacturer() String
Model getModel() String
Product getProduct() String
Fingerprint getFingerprint() String
Hardware getHardware() String
Radio Version getRadioVersion() String
Device getDevice() String
Board getBoard() String
Display Version getDisplayVersion() String
Build Brand getBuildBrand() String
Build Host getBuildHost() String
Build Time getBuildTime() long
Build User getBuildUser() String
Serial getSerial() String
Os Version getOsVersion() String
Language getLanguage() String
SDK Version getSdkVersion() int
Screen Density getScreenDensity() String
Screen Height getScreenHeight() int
Screen Density getScreenWidth() int

Memory

val memory = Memory(this)
Value Function Name Returns
Has External SD Card isHasExternalSDCard() boolean
Total RAM getTotalRAM() long
Available Internal Memory Size getAvailableInternalMemorySize() long
Total Internal Memory Size getTotalInternalMemorySize() long
Available External Memory Size getAvailableExternalMemorySize() long
Total External Memory Size getTotalExternalMemorySize() String

Network

val network = Network(this)
Value Function Name Returns
IMEI getIMEI() String
IMSI getIMSI() String
Phone Type getPhoneType() String
Phone Number getPhoneNumber() String
Operator getOperator() String
SIM Serial getsIMSerial() String
Network Class getNetworkClass() String
Network Type getNetworkType() String
Is SIM Locked isSimNetworkLocked() boolean
Is Nfc Present isNfcPresent() boolean
Is Nfc Enabled isNfcEnabled() boolean
Is Wifi Enabled isWifiEnabled() boolean
Is Network Available isNetworkAvailable() boolean

User Installed Apps

val userAppInfo = UserAppInfo(this)
val userApps:List<UserApps>  = userAppInfo.getInstalledApps(true);
Value Function Name Returns
App Name getAppName() String
Package Name getPackageName() String
Version Name getVersionName() String
Version Code getVersionCode() int

User Contacts

val userContactInfo = UserContactInfo(this)
val userContacts = userContactInfo.contacts
Value Function Name Returns
Contact Name getDisplayName() String
Mobile Number getMobileNumber() String
Phone Type phoneType() String

How to get Permissions for android 6+

Easy! I have provided a small, easy wrapper for getting permissions for marshmellow devices.

First, override onRequestPermissionsResult and call PermissionManager.handleResult(requestCode, permissions, grantResults);

private val permissionManager = PermissionManager(this)
    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)

        permissionManager.handleResult(requestCode, permissions, grantResults);
    }

Now you can ask permission:

permissionManager.showPermissionDialog(permission)
            .withDenyDialogEnabled(true)
            .withDenyDialogMsg(mActivity.getString(R.string.permission_location))
            .withCallback(object : PermissionCallback {
                override fun onPermissionGranted(
                    permissions: Array<String>,
                    grantResults: IntArray
                ) {
                    //you can handle what to do when permission is granted
                }

                override fun onPermissionDismissed(permission: String) {
                    /**
                     * user has denied the permission. We can display a custom dialog
                     * to user asking for permission
                     */
                }

                override fun onPositiveButtonClicked(dialog: DialogInterface, which: Int) {
                    /**
                     * You can choose to open the
                     * app settings screen
                     * *  */
                    val permissionUtils = PermissionUtils(this)
                    permissionUtils.openAppSettings()
                }

                override fun onNegativeButtonClicked(dialog: DialogInterface, which: Int) {
                    /**
                     * The user has denied the permission!
                     * You need to handle this in your code
                     * *  */
                }
            })
            .build()

Various options available in PermissionManager

Value Function Name Returns
To enable custom dialog when user has denied the permission withDenyDialogEnabled() boolean
To enable Rationale, explaining the need for the permission, the first time they have denied the permission withRationaleEnabled() boolean
Message to be displayed in the custom dialog withDenyDialogMsg() String
Title to be displayed in the custom dialog withDenyDialogTitle() String
Postive Button text to be displayed in the custom alert dialog withDenyDialogPosBtnText() String
Negative Button text to be displayed in the custom alert dialog withDenyDialogNegBtnText() String
Should display the negative button flag withDenyDialogNegBtn() boolean
Flag to cancel the dialog isDialogCancellable() boolean

Author

Klejvi Kapaj - @kl3jvi on GitHub, @kl3jvi on Twitter

You might also like...
A nice weather that helps you get all information including: current weather, hourly weather and also forecasts for 16 days
A nice weather that helps you get all information including: current weather, hourly weather and also forecasts for 16 days

WeatherForecast This is an ongoing project where I fetch all the weather data using Retrofit and Kotlin Coroutines over two APIs containing both curre

Clean MVVM with eliminating the usage of context from view models by introducing hilt for DI and sealed classes for displaying Errors in views using shared flows (one time event), and Stateflow for data

Clean ViewModel with Sealed Classes Following are the purposes of this repo Showing how you can remove the need of context in ViewModels. I. By using

[prototype] Generate TypeScript interfaces from Kotlin classes

Kotlinx Serialization TypeScript Generator Kotlinx Serialization TypeScript Generator creates TypeScript interfaces from Kotlinx Serialization classes

The Klutter CLI tool gives access to all tasks to create and manage a Klutter project.

Klutter CLI The Klutter CLI tool gives access to all tasks to create and manage a Klutter project. Gettings started Download the tool. Unzip the file.

A set of highly-opinionated, batteries-included gradle plugins to get you started building delicious multi-module Kotlin projects

Sourdough Gradle What is Sourdough Gradle? Sourdough is a set of highly opinionated gradle plugins that aim to act as the starter for your Kotlin proj

Android Ptrace Inject for all ABIs and all APIs. Help you inject Shared Library on Android.

Android Ptrace Inject 中文可以参考我的注释内容进行理解 我写的注释相对来说比较全面了 How to build Make sure you have CMake and Ninja in your PATH Edit CMakeLists.txt. Set ANDROID_ND

A simple Kotlin wrapper around Anvil.

AnvilKotlin A simple Kotlin wrapper around Anvil. The only purpose of this library is to provide type safety to Anvil through Kotlin. Nothing more, no

⏰ A powerful and simple-to-use guilded wrapper made in Kotlin.
⏰ A powerful and simple-to-use guilded wrapper made in Kotlin.

⏰ guilded-kt [WIP] A powerful yet simple-to-use guilded wrapper made entirely in Kotlin with supporting multiplatform. Take a look at an example of th

🎲 A powerful and simple-to-use guilded wrapper made in Kotlin.

🎲 deck [WIP] Deck is a powerful yet simple-to-use guilded wrapper made entirely in Kotlin with support to multiplatform. Implementating In case you'r

Releases(1.0.0)
Owner
Klejvi Kapaj
I'm a Software Engineer
Klejvi Kapaj
Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Vehement 8 Nov 26, 2022
A mobile application developed for *Android* devices, aimed at 11th grade students in which they can take some basic training tests for presentation of external tests.

ApliKTest11 Application with Kit of questions and Knowledge Test for the preparation of the Saber Test. Description A mobile application developed for

Mike Molina 0 Dec 13, 2021
A Kotlin Multiplatform and Compose template that allows you to easily set up your project targeting: Android, Desktop, and Web

A Kotlin Multiplatform and Compose template that allows you to easily set up your project targeting: Android, Desktop, and Web

Carlos Mota 3 Oct 27, 2021
👋 A common toolkit (utils) ⚒️ built to help you further reduce Kotlin boilerplate code and improve development efficiency. Do you think 'kotlin-stdlib' or 'android-ktx' is not sweet enough? You need this! 🍭

Toolkit [ ?? Work in progress ⛏ ?? ??️ ?? ] Snapshot version: repositories { maven("https://s01.oss.sonatype.org/content/repositories/snapshots") }

凛 35 Jul 23, 2022
A simple and easy adapter for RecyclerView. You don't have to make adapters and view holders anymore. Slush will help you.

한국어 No more boilerplate adapters and view holders. Slush will make using RecyclerView easy and fast. The goal of this project is to make RecyclerView,

SeungHyun 26 Sep 13, 2022
DocuBox is a cloud based file storing app where you can securely store and access your documents from anywhere around the world

DocuBox is an android app ??in which you can securely upload your files on the cloud– from family pictures and audio recordings to spreadsheets, presentations and other confidential documents.

Vaibhav Jaiswal 26 Jan 3, 2023
An android application for creating a journal for subjects you studied and also you can set timer for break.

Study Journal An android application for creating a journal for subjects you studied and also you can set timer for break between two consecutive subj

Prasoon 3 Aug 10, 2022
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

Darwin Francis 58 Nov 1, 2022
A React Native library making file access easier for developers as first class citizens, without the tears

React Native File Gateway A React Native library making file access easier for developers as first class citizens, without the tears. ⚠️ NOTE: This li

Jimmy Wei 4 Sep 11, 2021