Coder Social home page Coder Social logo

nisrulz / easydeviceinfo Goto Github PK

View Code? Open in Web Editor NEW
1.8K 50.0 228.0 2.43 MB

:iphone: [Android Library] Get device information in a super easy way.

License: Apache License 2.0

Java 95.43% Kotlin 4.57%
android easydeviceinfo android-library mod device information annotations library details cpu battery bluetooth location nfc memory display identifier network telephony sensor

easydeviceinfo's Introduction

EasyDeviceInfo

Android library to get device information in a super easy way.

The library is built for simplicity and approachability. It not only eliminates most boilerplate code for dealing with device information, but also provides an easy and simple API to retrieve them


Built with โค๏ธŽ by Nishant Srivastava and contributors


Note

EasyDeviceInfo is split into multiple module-libraries , v2.2.0 onwards. Use the appropriate one as per your requirement.

Changelog

Starting with 1.1.8, Changes exist in the releases tab.

Including in your project

EasyDeviceInfo is available in the Jcenter, so getting it as simple as adding it as a dependency.

dependencies {
    def easyDeviceInfoVersion = {latest version}

    // Base + Ads Bundled Library
    implementation "com.github.nisrulz:easydeviceinfo:$easyDeviceInfoVersion"

    // Base Composite
    implementation "com.github.nisrulz:easydeviceinfo-base:$easyDeviceInfoVersion"

    // Ads Composite
    implementation "com.github.nisrulz:easydeviceinfo-ads:$easyDeviceInfoVersion"
}

where {latest version} corresponds to published version in Jcenter

  • easydeviceinfo - Jcenter
  • easydeviceinfo-ads - Jcenter
  • easydeviceinfo-base - Jcenter

Usage Docs/Wiki

Introducing Mods in EasyDeviceInfo v2!

Mods or Modules are the new way to retrieve information. They let you get information in a very segmented manner and the best part is you only initialize the Mods you need in your project. Pretty rad , eh ? I know.

The whole api has been reworked in v2.x.x , however the functions remain the same, hence now you need to migrate to v2.x.x from 1.x.x.

Simple example

Now to use them, create an instance of one of the Mods ( Easy*Mod class ), i.e EasyConfigMod

EasyConfigMod easyConfigMod = new EasyConfigMod(context);

Next call an available function on the easyConfigMod instance such as

String time_in_ms= String.valueOf(easyConfigMod.getTime());

Now each Mods has a certain set of functions you can call on them to retrieve device information. i.e for EasyConfigMod

Value functionName returns
Is running on emulator isRunningOnEmulator() boolean
Time (ms) getTime() long
Formatted Time (24Hr) getFormattedTime() String
Up Time (ms) getUpTime() long
Formatted Up Time (24Hr) getFormattedUpTime() String

Android Studio support

  • Include a required permission check

    PermissionCheck

  • Setup all constants returned in a switch statement

    SetupSwitch

    This applies to all annotations bundled with easydeviceinfo. Checkout the wiki to see where these annotations can be applied.

    • @RingerMode
    • @DeviceType
    • @PhoneType
    • @OrientationType
    • @NetworkType
    • @BatteryHealth
    • @ChargingVia

๐Ÿ“ƒ For more info , check the Wiki Docs

Pull Requests

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults. This project uses a modified version of Grandcentrix's code style, so please use the same when editing this project.
  2. If its a feature, bugfix, or anything please only change code to what you specify.
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
  4. Pull requests must be made against develop branch. Any other branch (unless specified by the maintainers) will get rejected.
  5. Check for existing issues first, before filing an issue.
  6. Have fun!

Apps using EasyDeviceInfo

If you are using EasyDeviceInfo in your app and would like to be listed here, please let me know by opening a new issue!

Other apps using EasyDeviceInfo, via AppBrain Stats

Author & support

This project was created by Nishant Srivastava but hopefully developed and maintained by many others. See the the list of contributors here.

If you appreciate my work, consider buying me a cup of โ˜• to keep me recharged ๐Ÿค˜

  • PayPal
  • Bitcoin Address: 13PjuJcfVW2Ad81fawqwLtku4bZLv1AxCL

I love using my work and I'm available for contract work. Freelancing helps to maintain and keep my open source projects up to date!

easydeviceinfo's People

Contributors

dustedrob avatar nisrulz avatar nowke avatar toantran-ea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easydeviceinfo's Issues

Error:(75, 0) Could not get unknown property 'GROUP' for object of type org.gradle.api.internal.plugins.DefaultExtraPropertiesExtension.

Do you want to request a feature or report a bug?

What is the current behavior?
Error:(75, 0) Could not get unknown property 'GROUP' for object of type org.gradle.api.internal.plugins.DefaultExtraPropertiesExtension.
Open File
If the current behavior is a bug, please provide the steps to reproduce.

Any logs, error output, bugreport etc?

What is the expected behavior?

Any other comments?

ALSO POM VALUES ARE MISSING
<--
developerId = POM_DEVELOPER_ID
developerName = POM_DEVELOPER_NAME
developerEmail = POM_DEVELOPER_EMAILID

licenseName = POM_LICENCE_NAME
licenseUrl = POM_LICENCE_URL
allLicenses = [POM_ALL_LICENCES]
-->
sims like maven dependency missing
how to resolve
What versions of software are you using?

  • Device Information:

  • Android Version:

  • Configuration Information:

  • Misc:

Migrate old support libraries to AndroidX

Hi there!

First of all your library is very handy, thank you for that!
But there is one thing, I would already like to get rid of Android jetifier which transforms support libraries to the AndroidX ones.

easydeviceinfo-base contains a dependency com.android.support:support-annotations:27.0.2 - could we get rid of it and replace it to the androidx.annotations?

App gives carrier info about sim1 only

My mobile is dual sim, all the features are working fine but it only shows carrier info for sim1 automatically. It would be great if shows the number of sim present and carrier info for each of the available sim.

Add missing zero for device time

Please add the missing zero for the device time.

E.g if it's 04:09:42 o'clock
the method getFormatedTime() will return 4:9:42

It would be better to have it correctly formatted to return 04:09:42

Can not build project from console

I've got the following error during gradlew build:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

It looks like gradle wrapper jar file was missed in "gradle/wrapper".

Invalid External Storage Path

I got the following crash from an user on a Samsung Galaxy Tab 2 (Android 9.0)

Fatal Exception: java.lang.IllegalArgumentException
Invalid path: /storage/emulated/0
android.os.StatFs.doStat (StatFs.java:51)
android.os.StatFs.<init> (StatFs.java:41)
github.nisrulz.easydeviceinfo.base.EasyMemoryMod.getAvailableExternalMemorySize (EasyMemoryMod.java:147)
Caused by android.system.ErrnoException
statvfs failed: ENOENT (No such file or directory)
libcore.io.Linux.statvfs (Linux.java)
libcore.io.BlockGuardOs.statvfs (BlockGuardOs.java:333)
android.system.Os.statvfs (Os.java:570)
android.os.StatFs.doStat (StatFs.java:49)
android.os.StatFs.<init> (StatFs.java:41)
github.nisrulz.easydeviceinfo.base.EasyMemoryMod.getAvailableExternalMemorySize (EasyMemoryMod.java:147)

A quick StackOverflow search shows me that the reason it crashes is because you can't assume that an external storage exists.

Currently wrapping getAvailableExternalMemorySize() in a try catch to prevent crash.

app start err

java.lang.RuntimeException: Unable to start activity ComponentInfo{in.excogitation.deviceinfo/in.excogitation.deviceinfo.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2528)
    at android.app.ActivityThread.access$800(ActivityThread.java:169)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5552)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference
    at in.excogitation.a.a.I(Unknown Source)
    at in.excogitation.deviceinfo.MainActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:5975)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
    ... 10 more

build error

hi
i can't build check this error
Error:Execution failed for task ':app:processDebugResources'.

Error: more than one library with package name 'com.google.android.gms'
in my gradle

compile 'com.google.android.gms:play-services-maps:7.8.0'

Mistake in wiki

Hello!
String ua = easyDeviceMod.getUA() should be String ua = easyIdMod.getUA();

import this into android studio

hi,
when import this into studio,have a mistake
groovy.lang.MissingPropertyException: Could not get unknown property 'GROUP' for object of type org.gradle.internal.extensibility.DefaultExtraPropertiesExtension.

can you please tell me how to do?thanks very much

[Feature Req] Monitor values for change and emit the updated value

@nisrulz

Clarification-will it monitor and give json of each module? It will be good it can deliver device info whenever changes happening. Thank you!

Do you want to request a feature or report a bug?
feature
What is the current behavior?
need to call function and get info. but it would be nice if i can info whenever the changes happening.. let us say my device switched from mobile data to wifi , then the library will notify me about that event so that I can update my UI

If the current behavior is a bug, please provide the steps to reproduce.

similar to this library
https://github.com/appzy/DeviceInfo

android.permission.INTERACT_ACROSS_USERS Crash on Marshmallow (Android 6.1)

Calling areFingerprintsEnrolled causes a crash for Samsung users on Android Marshmallow (6.1).
Error:

Caused by java.lang.SecurityException
Permission Denial: getCurrentUser() from pid=9160, uid=10126 requires android.permission.INTERACT_ACROSS_USERS
github.nisrulz.easydeviceinfo.base.EasyFingerprintMod.areFingerprintsEnrolled

Stacktrace:

android.os.Parcel.readException (Parcel.java:1621)
android.os.Parcel.readException (Parcel.java:1574)
android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints (IFingerprintService.java:503)
android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints (FingerprintManager.java:776)
github.nisrulz.easydeviceinfo.base.EasyFingerprintMod.areFingerprintsEnrolled (EasyFingerprintMod.java:79)

For now, my solution is to disable fingerprint check for users on Marshmallow.
Any ideas what might be happening?

Get Android Advertiser ID issue

Hello.
There is a mistake in the next code:

easyIdMod.getAndroidAdId(MainActivity.this, new EasyIdMod.AdIdentifierCallback() {
    @Override
    public void onSuccess(String adIdentifier, boolean adDonotTrack) {
        // Do something with the advertiser's ID
    }
});

you have easyIdMod here, but it doesn't have function getAndroidAdId.
Maybe here should be easyAdsMod?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.