/android-device-identification

Library for unique identification of an Android device. Provides also a backup solution

Primary LanguageJavaApache License 2.0Apache-2.0

Android Device Identification

Download Build Status

Library for unique identification of an Android device. Provides also a backup solution

Overview

TBD

Release Notes:

0.0.2

  • A secure preference store is used for holding the device specific data.
  • Backup manager helper added for backing up preferences and sqlite databases.

0.0.1

  • Initial import to github. I've added several ways to identify an android device.
  • device specific data is written to shared preferences.

Usage

To make use of the device identification you only need to add an DeviceIdentityProvider to your activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...

    identityProvider = DeviceIdentityProvider.getInstance(this);

    // force backup for new device immediately
    if (identityProvider.isNewDevice()) {
        BackupManager backupManager = new BackupManager(this);
        backupManager.dataChanged();
    }

    ...
}

If you want automatically backup your application data to android backup service you need to add some snippets to the applications manifest an an activity:

<application android:backupAgent="com.thomashaertel.device.backup.SimpleBackupAgent" android:allowBackup="true" ...>
    <meta-data android:name="com.google.android.backup.api_key" android:value="your-api-key" />
    ...
</application>
@Override
protected void onStop() {
    // allow backup authorized devices only
    if (identityProvider.isAuthorizedDevice()) {
        BackupManager backupManager = new BackupManager(this);
        backupManager.dataChanged();
    }

    super.onStop();
}

Building

Gradle

From Bintray

Add maven central to your build.gradle:

buildscript {
  repositories {
    jcenter()
  }
}

repositories {
  jcenter()
}

From maven central

Add maven central to your build.gradle:

buildscript {
  repositories {
    mavenCentral()
  }
}

repositories {
  mavenCentral()
}

Then declare android-device-identification within your dependencies:

dependencies {
  ...
  compile('com.thomashaertel:android-device-identification :0.0.2@aar') {
  }
  ...
}

Maven

From maven central

To use android-device-identification within your maven build simply add

<dependency>
  <artifactId>android-device-identification </artifactId>
  <version>${android-device-identification .version}</version>
  <groupId>com.thomashaertel</groupId>
</dependency>

to your pom.xml

If you also want the sources or javadoc add the respective classifier

  <classifier>sources</classifier>

or

  <classifier>javadoc</classifier>

to the dependency.

Contributing

For making contributions please send me pull requests, but also bugs and enhancement requests are welcome. Although no guarantees on when I can review them.

License