Question

need help to build a App in Adroid Studio for finger print to secure and lock...

need help to build a App in Adroid Studio for finger print to secure and lock folder from computer
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOURCE CODE:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:padding="20dp"
android:text="Fingerprint Authentication"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

<TextView
android:id="@+id/paraMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Place your finger on the fingerprint scanner to proceed"
android:textAlignment="center"
android:textColor="@color/colorAccent"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fingerprint_image_view"
app:layout_constraintVertical_bias="0.178" />

<ImageView
android:id="@+id/fingerprint_image_view"
android:layout_width="110dp"
android:layout_height="119dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/heading"
app:layout_constraintVertical_bias="0.029"
app:srcCompat="@drawable/fingerprint_icon" />
</android.support.constraint.ConstraintLayout>

FingerprintHandler.java (Model class)

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
import android.support.v4.content.ContextCompat;
import android.widget.ImageView;
import android.widget.TextView;

@TargetApi(Build.VERSION_CODES.M)
public class FingerprintHandler extends FingerprintManager.AuthenticationCallback {

private Context context;

public FingerprintHandler(Context context)
{
this.context = context;
}

public void startAuth(FingerprintManager fingerprintManager, FingerprintManager.CryptoObject cryptoObject)
{
CancellationSignal cancellationSignal = new CancellationSignal();
fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}

@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
this.update("There was an auth error: " + errString, false);
}

@Override
public void onAuthenticationFailed() {
this.update("Authentication failed!", false);
}

@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
this.update("Error: " + helpString, false);
}

@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
this.update("You can now access the app!", true);
}

public void update(String s, boolean b)
{
TextView paraMessage = (TextView) ((Activity) context).findViewById(R.id.paraMessage);
ImageView fingerPrintImageView = (ImageView) ((Activity) context).findViewById(R.id.fingerprint_image_view);

paraMessage.setText(s);

if(b == false)
{
paraMessage.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary));
}
else
{
paraMessage.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
fingerPrintImageView.setImageResource(R.drawable.done_icon);
}
}
}

MainActivity.java

import android.Manifest;
import android.app.KeyguardManager;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private TextView heading, paraMesaage;
private ImageView fingerPrintImageView;

private FingerprintManager fingerprintManager;
private KeyguardManager keyguardManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

heading = (TextView) findViewById(R.id.heading);
paraMesaage = (TextView) findViewById(R.id.paraMessage);
fingerPrintImageView = (ImageView) findViewById(R.id.fingerprint_image_view);

/*
* TODO
* 1. Check: Android version should be greater than Marshmallow
* 2. Check: Device has fingerprint scanner
* 3. Check: Have permissions to use fingerprint scanner in the device
* 4. Check: Lock screen is secured with at least 1 type of lock
* 5. Check: At least 1 fingerprint is registered
/

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);

// Add <uses-permission android:name="android.permission.USE_FINGERPRINT"/>
// this line to AndroidManifest.xml file

if(!fingerprintManager.isHardwareDetected())
{
paraMesaage.setText("Fingerprint Scanner not detected in your device!");
}
else if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.USE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED)
{
paraMesaage.setText("Permission not granted to use Fingerprint Scanner!");
}
else if(!keyguardManager.isKeyguardSecure())
{
paraMesaage.setText("Add lock to your device in Device Settings!");
}
else if(!fingerprintManager.hasEnrolledFingerprints())
{
paraMesaage.setText("You should add at least 1 fingerprint to use this feature!");
}
else
{
paraMesaage.setText("Place your finger on the fingerprint scanner to proceed");

FingerprintHandler fingerprintHandler = new FingerprintHandler(MainActivity.this);
fingerprintHandler.startAuth(fingerprintManager, null);
}
}
}
}

Add a comment
Know the answer?
Add Answer to:
need help to build a App in Adroid Studio for finger print to secure and lock...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help to build a fingerprint app that we have sslserversocket to tell a file use finger print...

    need help to build a fingerprint app that we have sslserversocket to tell a file use finger print before open the file what have been done below Here is my mainactivity.java and fingerprintHandler.java below <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:padding="20dp" android:text="Fingerprint Authentication" android:textAlignment="center" android:textColor="@android:color/black" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" /> <TextView android:id="@+id/paraMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:text="Place your finger on the fingerprint scanner to...

  • I need help developing this app using java in android studio Assignment: Tic-Tac-Toe app User interface...

    I need help developing this app using java in android studio Assignment: Tic-Tac-Toe app User interface Operation The app allows the user to play a game of Tic-Tac-Toe. The user can click the New Game button at any time to start a new game. The app displays other messages to the user as the game progresses such as (1) whose turn it is, (2) if a player wins, and (3) if the game ends in a tie. Specifications The app...

  • using c# visual studio 3.28 (Digits of an Integer) Write an app that inputs one number...

    using c# visual studio 3.28 (Digits of an Integer) Write an app that inputs one number consisting of five digits from the user, separates the number into its individual digits and displays the digits separated from one another by three spaces each. For example, if the user types 42339, the app should display 4 2 3 3 9 Assume that the user enters the correct number of digits. What happens when you execute the app and type a number with...

  • Write a C# Windows Forms App code in Visual studio with a "start", "stop", "up", "down",...

    Write a C# Windows Forms App code in Visual studio with a "start", "stop", "up", "down", "left" and "right" buttons and a textbox. The textbox should start printing numbers from 1 to 100 on the press of the "start" button and stop printing process immediately on the press of "stop" button. Also create a thread after stop button is pressed to allow manual input from  "up", "down", "left" and "right" buttons and print up, down, left or right in the same...

  • P10-3 (similar to) Question Help Opportunity cost. Revolution Records will build a new recording studio on a vacant lot...

    P10-3 (similar to) Question Help Opportunity cost. Revolution Records will build a new recording studio on a vacant lot next to the operations center. The land was purchased five years ago for $450,000. Today, the value of the land has appreciated to $790,000. Revolution Records did not consider the value of the land in its NPV calculations for the studio project (it had already spent the money to acquire the land long before this project was considered). The NPV of...

  • Using java in android studio, I need help in making a barcode scanner thanks for the...

    Using java in android studio, I need help in making a barcode scanner thanks for the help

  • Using java in android studio, I need help in making a text to speech button that...

    Using java in android studio, I need help in making a text to speech button that reads off of my text view thanks for the help

  • C# Sharp for Visual Studio Need Expert help -to use Video studio to write a Quiz....

    C# Sharp for Visual Studio Need Expert help -to use Video studio to write a Quiz. The quiz is multiple choice with 10 questions. I need a source code to start and I can copy and paste my questions. EX: using System; namespace Quiz     class MainClass     {         public static void Main(string[] args)         {         Console.WriteLine("Welcome to the Quiz!");             Console.WriteLine("");                 // Declare variables implicitly and explicitly             var Question 1= "How many trees in a forest?");                var Answer1a = "3"                    var Answer1b ="5"...

  • Need help with this question! Exercise 22-6 Alma's Recording Studio rents studio time to musicians in...

    Need help with this question! Exercise 22-6 Alma's Recording Studio rents studio time to musicians in 2-hour blocks. Each session includes the use of the studio facilities, a digital recording of the performance, and a professional music producer/mixer. Anticipated annual volume is 1,020 sessions. The company has invested $2,341,000 in the studio and expects a return on investment (ROI) of 20%. Budgeted costs for the coming year are as follows. Total Per Session $ 19.94 $395.00 $ 45.00 Direct materials...

  • Need help with this in R studio! A screenshot of how to do it would be...

    Need help with this in R studio! A screenshot of how to do it would be helpful. Create a function called "printVecInfo" that take a vector as input. To receive a full credit, when you test your function using this input: printVecInfo(c(1,2,3,4,5,6,7,8,9,10,50)) The output should be: mean: 9.545455 median: 6 min: 1 max 50 sd: 13.72125 ****HINT: you can improvise this input inside of your function: cat("mean:", mean(vector), "\n")

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT