Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how getting fingerprint device id in java ? #67

Closed
AhmedHumk opened this issue Aug 27, 2022 · 3 comments
Closed

how getting fingerprint device id in java ? #67

AhmedHumk opened this issue Aug 27, 2022 · 3 comments

Comments

@AhmedHumk
Copy link

i tried to follow the documentation

// Initialization
Fingerprinter fingerprinter = FingerprinterFactory
				.getInstance(getApplicationContext(), new Configuration(4));


// Usage
fingerprinter.getFingerprint(new Function1<FingerprintResult, Unit>() {
        @Override
        public Unit invoke(FingerprintResult fingerprintResult) {
        	String fingerprint = fingerprintResult.getFingerprint();
        	    return null;
            }
        });

but what is function1 and unit ? unit refer to kotlin unit and i try to test in java

@Alexey-Verkhovsky
Copy link
Member

Hello!

Make sure you added kotlin-stdlib as a dependency to the module where you plan to use the library. kotlin-stdlib is a small library that has great backward and forward compatibility, so it won't cause troubles for your java application.

dependencies {
  // Add this line!!!
  implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.31"

  implementation "com.github.fingerprintjs:fingerprint-android:1.2"
}

After you did it – Android Studio will suggest you corresponding imports.

@AhmedHumk
Copy link
Author

Thank you for replay but i still cant figure what is function1

@Alexey-Verkhovsky
Copy link
Member

Function1 is an analog for lambda function for Java 6.

Kotlin initially was supporting lambdas while Java 6 does not. Due to have interoperability with Java 6 this class appeared. If Java in your project has version which supports lambdas, Android Studio will suggest you simplify this to:

fingerprinter.getFingerprint(fingerprintResult -> {
    String fingerprint = fingerprintResult.getFingerprint();
    return null;
});

fingerprinter.getDeviceId(deviceIdResult -> {
    String deviceId = deviceIdResult.getDeviceId();
    return null;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants