Click here to Skip to main content
15,887,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,

Im wondering is it possible, to restrict a certain users actions like not be able to press certain buttons and views of what they can and cannot see in the app. The user would initial log in using their fingerprint . And based on their security level they could only view/run certain things in the app?

What I have tried:

I have been looking at demo protects for fingerprint scanners that unlock a phone,but is it possible give or restrict access to certain activities/fragments/buttons/charts/graphs within an app?
Posted
Updated 15-Sep-16 22:26pm
Comments
Richard MacCutchan 12-Sep-16 5:49am    
Yes it is possible within an application, but why would you need this?
BEBE2011 12-Sep-16 5:54am    
Could you point me in the right direction? One device will be used by many different people with different security levels in one area.
Richard MacCutchan 12-Sep-16 5:59am    
Then you will need to set up a database with all the user information and security levels. you application then presents data according to the security levels of the user that logs in.
BEBE2011 12-Sep-16 6:01am    
That is ok, i was thinking that it needed to be done.
BEBE2011 12-Sep-16 6:32am    
Who could i prevent them doing certain actions in the app?

1 solution

Yes you can. Just launch a fingerprint helper when someone entering the restricted area. With a button click something like:

Java
public void onClick(View v) {
        if (v.getId() == R.id.cancel_button) {
            finish();
        }
        if (v.getId() == R.id.learn_more_button) {
            launchFingerprintHelp();
        }
        super.onClick(v);
    }


Launch:
C#
private void launchFingerprintHelp() {
       Intent helpIntent = HelpUtils.getHelpIntent(this,
               getString(R.string.help_url_fingerprint), getClass().getName());
       startActivity(helpIntent);
   }


Than finish it with onactivity and read if the acces was suceed:

Java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_FINISHED) {
        finish();
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}





Here you have a full preview of what it should like:

Java
package com.android.settings.fingerprint;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.View;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.HelpUtils;
import com.android.settings.R;
/**
 * Onboarding activity for fingerprint enrollment.
 */
public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {
    private boolean mHasPassword;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fingerprint_enroll_introduction);
        setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title);
        findViewById(R.id.cancel_button).setOnClickListener(this);
        findViewById(R.id.learn_more_button).setOnClickListener(this);
        final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
                .getActivePasswordQuality(UserHandle.myUserId());
        mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
    }
    @Override
    protected void onNextButtonClick() {
        Intent intent = new Intent();
        final String clazz;
        if (!mHasPassword) {
            // No fingerprints registered, launch into enrollment wizard.
            clazz = FingerprintEnrollOnboard.class.getName();
        } else {
            // Lock thingy is already set up, launch directly into find sensor step from wizard.
            clazz = FingerprintEnrollFindSensor.class.getName();
        }
        intent.setClassName("com.android.settings", clazz);
        startActivityForResult(intent, 0);
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_FINISHED) {
            finish();
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.cancel_button) {
            finish();
        }
        if (v.getId() == R.id.learn_more_button) {
            launchFingerprintHelp();
        }
        super.onClick(v);
    }
    private void launchFingerprintHelp() {
        Intent helpIntent = HelpUtils.getHelpIntent(this,
                getString(R.string.help_url_fingerprint), getClass().getName());
        startActivity(helpIntent);
    }
}


Goodluck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900