Reusing Android Lock Pattern

I am writing an application and it must be password protected. Instead of creating a new one, is it possible to use the Android Pattern lock screen from an application with different patterns?

+3
source share
1 answer

First you need to configure the pattern lock by going to the setup manually. then you can receive events using the code below. `

import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;


public class DemoDeviceAdminReceiver extends DeviceAdminReceiver {
        static final String TAG = "DemoDeviceAdminReceiver";

        /** Called when this application is approved to be a device administrator. */
        @Override
        public void onEnabled(Context context, Intent intent) {
                super.onEnabled(context, intent);
                Toast.makeText(context, R.string.device_admin_enabled,
                                Toast.LENGTH_LONG).show();
                Log.d(TAG, "onEnabled");
        }

        /** Called when this application is no longer the device administrator. */
        @Override
        public void onDisabled(Context context, Intent intent) {
                super.onDisabled(context, intent);
                Toast.makeText(context, R.string.device_admin_disabled,
                                Toast.LENGTH_LONG).show();
                Log.d(TAG, "onDisabled");
        }

        @Override
        public void onPasswordChanged(Context context, Intent intent) {
                super.onPasswordChanged(context, intent);
                Log.d(TAG, "onPasswordChanged");
        }

        @Override
        public void onPasswordFailed(Context context, Intent intent) {
                super.onPasswordFailed(context, intent);
                Log.d(TAG, "onPasswordFailed");
        }

        @Override
        public void onPasswordSucceeded(Context context, Intent intent) {
                super.onPasswordSucceeded(context, intent);
                Log.d(TAG, "onPasswordSucceeded");
        }



}

For a complete understanding, please read this. Full code and explanation

-1
source

Source: https://habr.com/ru/post/1772337/


All Articles