Android fingerprint cancellationSignal FINGERPRINT_ACQUIRED_TOO_FAST - java

What I do:
I am using the following tutorial to grasp the basic understanding on how to use fingerprint authentication in Android:
http://joerichard.net/android/android-fingerprint-example/
I basically follow it except that I added a button and I want to authenticate a user when the button is clicked.
So I have the following changes
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
authentication();
}
});
...
protected void authentication(/* Bundle savedInstanceState */) {
//super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
...
My problem:
When I click the button the following notification is called (in "FingerprintHandler.java"):
Toast.makeText(appContext,
"Authentication error\n" + errString ,
Toast.LENGTH_LONG).show();
The errString is Fingerprint operation canceled.
and the Error message ID is 5.
By searching I found here that it correspond to FINGERPRINT_ACQUIRED_TOO_FAST, however I don't understand why this happen.
What I tried:
I tried to click the button while having my finger on the scanner but
the notification is immediate which make me believe that it does not
even listen/scan for a fingerprint.
I have also tried to make it work without the button but in that case
nothing happens.
If you see what could go wrong or have directions in which I could investigate let me know.
Thank you.

My sensor was not working very well. It takes many tries to have a reading (and some time it does not work at all).
Thus I would re-try by clicking on the button causing the error.
The function would not have any reading from the scanner when clicked again the button and give the error FINGERPRINT_ACQUIRED_TOO_FAST.
The fact that this specific error (TOO_FAST) is trigger didn't help me in my situation because as I explained this error message is trigger when clicking the button.
If anyone encounter the same problem give more time/chances to your sensor to recognize that a finger is being read.

Related

2 buttons in front page, each button get different function to another page

I was watching and tried to do the tutorial for the generator QR Code in this video.
And then like in the end of it when he want to try the generator works, he shows some kind a 2 buttons, 1 for the scanner and 1 for the generator.
But in the video he didn't explain how he do it. I already tried his video about the scanner but still no clue. Can someone help me?
UPDATE:
Now here's my new problem regarding with gradle version:
Error:Could not find com.android.tools.build:gradle:2.10.
Searched in the following locations:
file:/C:/Users/User/Downloads/android-studio-ide-171.4443003-windows32/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.pom
file:/C:/Users/User/Downloads/android-studio-ide-171.4443003-windows32/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/2.10/gradle-2.10.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/2.10/gradle-2.10.jar
https://maven.google.com/com/android/tools/build/gradle/2.10/gradle-2.10.pom
https://maven.google.com/com/android/tools/build/gradle/2.10/gradle-2.10.jar
Required by:
:QRCode:unspecified
Open File
Anybody can help me fix this?
Look at the description of the Youtube video, there is a link to the source code
https://github.com/prudhvirajkumar10/QR-Code/
download the source code and open MainActivity.java
#Line 10 in MainActivity.java he declared the two buttons like this,
Button gen, scan; // gen for generate and scan for scanning qr code
Again in MainActivity.java you can see this code,
gen.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent gIntent = new Intent(MainActivity.this, GeneratorActivity.class);
startActivity(gIntent);
}
});
The above "OnClickListener" gets executed when the gen button is pressed. When "GENERATE" button is pressed it moves from MainActivity to the GeneratorActivity which you can find in "GeneratorActivity.java"
Similar thing happens when clicking scan button, Look at these code in MainActivity.java
scan.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent rIntent = new Intent(MainActivity.this, ReaderActivity.class);
startActivity(rIntent);
}
});
When "SCAN" button is clicked it changes from MainActivity to ReaderActivity which is found in "ReaderActivity.java".
If you have any doubt feel free to ask me.

Switch goes back to off

When turn the switch on it stays on.. however when i leave the activity and come back to it.. it goes back to off. I want it to stay ON OR OFF depending on whats last pressed. I have tried the code below but does not resolve my issue
SwitchButton.setChecked(true);
SwitchButton.setChecked(false);
What you need to do is override these methods in your activity:
#Override
protected void onSaveInstanceState (Bundle outState){
super.onSaveInstanceState(outState);
outState.putBoolean("CHECKED", SwitchButton.isChecked());
}
then in onCreate:
#Override
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstaceState);
if(savedInstanceState != null){
boolean isChecked = savedInstanceState.getBoolean("CHECKED");
SwitchButton.setChecked(isChecked);
}
}
If you are minimizing the activity and then returning back to it, and you want all controls to retain their states, then look into implementing saved instance state. This will persist the control values while you minimize / maximize the activity or rotate it. No data is permanently saved to the device. Sample code here:
http://developer.android.com/training/basics/activity-lifecycle/recreating.html#SaveState
If you are closing the app completely and want the app to remember the settings, then consider SharedPreferences, which can be used to save data locally on the device. The data persists until your app explicitly deletes it or you uninstall the app. Sample code here:
http://developer.android.com/training/basics/data-storage/shared-preferences.html

The difference between implementation of back and cancelbutton?

I m a newbie an trying to learn Java/Android-programming.
I m doing an app for Android in Eclipse and created some buttons.
I have a back and a cancel button.
Example:
I have a EditText there you can write in your name. If you write yourname and press the backbutton, then u will go back to the previous Activity, but if you go to the same Activity, then you will still see the name that you wrote in the EditText.
But if you press the cancelbutton, you will go back to the previous Activity, but when you come back, yourname will be empty. I will "kill" or "stop" the Activity.
This is the code I use for the Backbutton, what would you use for the Cancel Button?
Thank YOU.
public void onClick(View v) {
switch(v.getId()){
case R.id.buttonBack:
Intent intent = new Intent (AllActivity.this, MenuActivity.class);
startActivity(intent);
break;
For the cancel button you can use the below method, this will kill the activity.
finish()
so in your code it will look something like this:
public void onClick(View v) {
switch(v.getId()){
case R.id.cancel:
finish();
break;
There was little difference in this as per requirement of process or application flow. For cancel and back as work are same for example if you open any dialog and provide cancel button will close/dismiss your dialog same way the back button do this. While for implementing with the Activity you if you implement for closing current activity you can just finish with both option by just calling finish() method. As back button was normally work for finish you current activity and back.
Another way to do this that you may be interested in is to wipe out the content of the EditText yourself.
You would need to have in your xml file an id defined for the EditText so that you could access it programatically.
<EditText
layout stuff here:
android:layout_width="fill_parent"
...
and then the id attribute
android:id="#+id/edit_text_id"
>
then in your code you would put the following in your class (not inside any method):
EditText anEditText;
then in your onCreate(), after the inflation of the layout (if it comes beforehand it will cause the app to crash):
anEditText = (EditText) findViewById(R.id.edit_text_id);
the name edit_text_id is not significant, but it is what we used in the layout file
next add to the onClick method for cancel (after the case statement):
//this wipes the text from the textbox
anEditText.setText("");
// add the rest of the back button code after this and your good!
Best of luck! Remember that we were all newbies once. If you want to be a good android programmer, I suggest that you get a strong background in Java first. This free book helped me very much!
Java Notes

Removing ProgressDialog when user presses the back button

I have an activity that queries a server database and returns a list of results...while querying the app displays a simple progressDialog on the onCreate method like so:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//display progress dialog while querying server for values
final ProgressDialog dialog = ProgressDialog.show(this,"","Retrieving listings please wait...");
dialog.setCancelable(true);
dialog.show();
If the user clicks on an item from the list then another activity placeDetails is opened. Once done a user can press the back button to go back to the previous activity which displays the listings.
When I tested it naturally it shows the above dialog and sends the query back to the server even though the listings can be seen in the background of the progressDialog.
What I want to know is how would I prevent the database being queried again and the above progressDialog from displaying when the user presses the back button.
Do I have to go down the caching route? or is there another way?
1.) To prevent the database from being queried again you can simply cache this data in a local SQLite database as Tom Dignan mentioned.
2.) To prevent the progressDialog from displaying when the user presses the back button, simply override the onBackPressed() method of the current activity (when back is pressed) and set an Intent to the activity that preceeds the progresDialog. I believe there's even a method to do this so that you won't be starting a new instance of that activity but simply accessing a cached version.
I managed to solve this issue the missing link was I did not know how to check for dialog windows the following code helped:
//first declare the dialog so its accessible globally through out the class
public class ListPlaces extends ListActivity {
ProgressDialog dialog;
then on the onCreate first check that a dialog exists or not
if(dialog == null){
dialog = ProgressDialog.show(this,"","Retrieving listings please wait...");
//display progress dialog while querying server for values
dialog.setCancelable(true);
dialog.show();
}
And the mistake was I was using
dialog.hide();
instead of
dialog.dismiss();
Thanks for the contributions

Creating buttons in java

I'm pretty new to learning about java and android development; so please help me out. In the next line of code I am trying to create a button but I am having trouble understanding why the 'id' is underlined. When I fix it in the R folder the .blue_yes gets underlined and I am confused what I should do next? Any help would be helpful.
Thanks
Button yes = (Button) findViewById(R.id.blue_yes);
yes.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mBtAdapter.enable();
setResult(CheckBluetoothEnabledActivity.RESULT_SUCCESS);
finish();
}
});
Button cancel = (Button) findViewById(R.id.blue_cancel);
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(CheckBluetoothEnabledActivity.RESULT_CANCEL);
finish();
}
you should have a button in the layout xml file with id blue_yes and blue_cancel before accessing that control in your in your code. probably you have not declared the control in your xml file correctly.
Once you specify a control in Layout file entry in R.Java is automatically made by eclipse android plugin. you don't need to mess with R folder and its file as R.java in automatically generated file and you should not change anything in that.
if even after declaring your control in layout file you are not able to get your control using findViewById method then please post your layout file as well to help you further.
Given the data, one of gazillion possible explanations is that you don't have R imported (and then fix it by creating a new class, and the new class lacks the id attribute).

Categories

Resources