Computer >> Máy Tính >  >> Lập trình >> Android

Làm thế nào để kiểm tra thiết bị Android ngón tay in đã được đăng ký?

Ví dụ này minh họa về Cách kiểm tra dấu vân tay trên thiết bị Android đã được đăng ký

Bước 1 - Tạo một dự án mới trong Android Studio, đi tới Tệp ⇒ Dự án Mới và điền tất cả các chi tiết cần thiết để tạo một dự án mới.

Bước 2 - Thêm mã sau vào res / layout / activity_main.xml.

     

Trong đoạn mã trên, chúng tôi đã sử dụng chế độ xem văn bản để hiển thị thông tin trình quản lý dấu vân tay.

Bước 3 - Thêm mã sau vào src / MainActivity.java

 package com.example.myapplication; import android.annotation.SuppressLint; import android.app.usage.UsageEvents; import android.hardware.fingerprint.FingerprintManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; nhập android.support.v4.view.MotionEventCompat; nhập android.support.v7.app.AppCompatActivity; nhập android.util.Log; nhập android.util.LogPrinter; nhập android.view.DragEvent; nhập android.view.MotionEvent; nhập android.view.View; nhập android.view.View.OnTouchListener; nhập android.widget.Switch; nhập android.widget.TextView; nhập android.widget.Toast; nhập java.util. logging.LogManager; public class MainActivity mở rộng AppCompatActivity {TextView textView; @SuppressLint ({"RestrictedApi", "ClickableViewAccessibility"}) @RequiresApi (api =Build.VERSION_CODES.N) @Override được bảo vệ void onCreate (Gói đã lưuInstanceState) {super.onCreate (saveInstanceState); setContentView (R.layout.activity_main); TextView actionEvent =findViewById (R.id.actionEvent); FingerprintManagerprintManager =(FingerprintManager) getSystemService (FINGERPRINT_SERVICE); actionEvent.setText ("inger "+ dấu vân tayManager.hasEnrolled;} trước> 

Bước 4 - Thêm mã sau vào Manifest.xml

              

Hãy thử chạy ứng dụng của bạn. Tôi giả sử bạn đã kết nối thiết bị Di động Android thực tế với máy tính của mình. Để chạy ứng dụng từ android studio, hãy mở một trong các tệp hoạt động của dự án của bạn và nhấp vào biểu tượng Chạy từ thanh công cụ. Chọn thiết bị di động của bạn làm tùy chọn, sau đó kiểm tra thiết bị di động sẽ hiển thị màn hình mặc định của bạn -

Làm thế nào để kiểm tra thiết bị Android ngón tay in đã được đăng ký?