- Forum posts: 4
Jul 13, 2016, 11:40:23 AM via Website
Jul 13, 2016 11:40:23 AM via Website
I am trying to use the native Finger Print Scanning in my google nexus 5x. I am new to this development. I do not have any idea towards this issue. can I have some Guidance here?. My Design consist of dynamic fragment which ask for the user to touch the sensor. My development IDE is android eclipse. Below is the detail of the error.
07-12 15:04:50.419: I/Process(5519): Sending signal. PID: 5519 SIG: 9
07-12 15:14:55.328: I/art(6119): Ignoring second debugger -- accepting and dropping
07-12 15:14:55.355: W/System(6119): ClassLoader referenced unknown path: /data/app/com.example.fingerprintnew-1/lib/arm64
07-12 15:14:55.550: D/OpenGLRenderer(6119): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
07-12 15:14:55.597: I/Adreno(6119): QUALCOMM build : 63c06b2, I8366cd0437
07-12 15:14:55.597: I/Adreno(6119): Build Date : 12/06/15
07-12 15:14:55.597: I/Adreno(6119): OpenGL ES Shader Compiler Version: XE031.05.13.02
07-12 15:14:55.597: I/Adreno(6119): Local Branch : mybranch17112971
07-12 15:14:55.597: I/Adreno(6119): Remote Branch : quic/LA.BF64.1.2.9_v2
07-12 15:14:55.597: I/Adreno(6119): Remote Branch : NONE
07-12 15:14:55.597: I/Adreno(6119): Reconstruct Branch : NOTHING
07-12 15:14:55.603: I/OpenGLRenderer(6119): Initialized EGL, version 1.4
07-12 15:14:56.929: D/AndroidRuntime(6119): Shutting down VM
07-12 15:14:56.933: E/AndroidRuntime(6119): FATAL EXCEPTION: main
07-12 15:14:56.933: E/AndroidRuntime(6119): Process: com.example.fingerprintnew, PID: 6119
07-12 15:14:56.933: E/AndroidRuntime(6119): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.fingerprintnew.MainActivity.onAuthentication()' on a null object reference
07-12 15:14:56.933: E/AndroidRuntime(6119): at com.example.fingerprintnew.FingerPrintHandler.onAuthenticationSucceeded(FingerPrintHandler.java:63)
07-12 15:14:56.933: E/AndroidRuntime(6119): at android.hardware.fingerprint.FingerprintManager$MyHandler.sendAuthenticatedSucceeded(FingerprintManager.java:805)
07-12 15:14:56.933: E/AndroidRuntime(6119): at android.hardware.fingerprint.FingerprintManager$MyHandler.handleMessage(FingerprintManager.java:757)
07-12 15:14:56.933: E/AndroidRuntime(6119): at android.os.Handler.dispatchMessage(Handler.java:102)
07-12 15:14:56.933: E/AndroidRuntime(6119): at android.os.Looper.loop(Looper.java:148)
07-12 15:14:56.933: E/AndroidRuntime(6119): at android.app.ActivityThread.main(ActivityThread.java:5422)
07-12 15:14:56.933: E/AndroidRuntime(6119): at java.lang.reflect.Method.invoke(Native Method)
07-12 15:14:56.933: E/AndroidRuntime(6119): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-12 15:14:56.933: E/AndroidRuntime(6119): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Expectation :
The very first screen is having one button when the button is tapped, the dialog should appear which should be created dynamically and should sense the fingerprint
Below is the piece of code where i am getting the error.
package com.example.fingerprintscanning;
import com.example.fingerprintscanning.MainActivity;
import com.example.fingerprintscanning.FingerprintUiHelper;
import android.app.Activity;
import android.app.DialogFragment;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class FingerprintAuthenticationDialogFragment extends DialogFragment implements TextView.OnEditorActionListener {
private MainActivity mActivity;
private FingerprintManager mfingerprintManager;
private FingerprintUiHelper mFingerprintUiHelper;
private FingerprintManager.CryptoObject mCryptoObject;
private Color mColor;
private Stage mStage = Stage.FINGERPRINT;
RelativeLayout.LayoutParams param1,
param2,param3,param4;
public FingerprintAuthenticationDialogFragment(Context context) {
this.mActivity = (MainActivity)context;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Do not create a new Fragment when the Activity is re-created such as orientation changes.
setRetainInstance(true);
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().setTitle("Sign In");
int img = getResources().getIdentifier("ic_fp_40px", "drawable", this.mActivity.getPackageName());
FrameLayout framelayout = new FrameLayout(this.mActivity);
framelayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
RelativeLayout relativeLayout = new RelativeLayout(this.mActivity);
param1 = new RelativeLayout.LayoutParams((int)RelativeLayout.LayoutParams.WRAP_CONTENT,
(int)RelativeLayout.LayoutParams.WRAP_CONTENT);
param2 = new RelativeLayout.LayoutParams((int)RelativeLayout.LayoutParams.WRAP_CONTENT,
(int)RelativeLayout.LayoutParams.WRAP_CONTENT);
param3 = new RelativeLayout.LayoutParams((int)RelativeLayout.LayoutParams.WRAP_CONTENT,
(int)RelativeLayout.LayoutParams.WRAP_CONTENT);
param4 = new RelativeLayout.LayoutParams((int)RelativeLayout.LayoutParams.WRAP_CONTENT,
(int)RelativeLayout.LayoutParams.WRAP_CONTENT);
param1.setMargins(100, 50, 0, 0);
param1.height = 500;
param2.setMargins(100, 200, 0, 0);
param3.setMargins(300, 200, 0, 0);
param4.setMargins(450, 350, 0, 0);
TextView textView = new TextView(this.mActivity);
textView.setText("Confirm fingerprint to continue");
textView.setTextSize(17);
textView.setTextColor(mColor.GRAY);
textView.setPadding(0, 0, 0,0);
textView.setLayoutParams(param1);
ImageView image = new ImageView(this.mActivity);
image.setLayoutParams(param2);
image.setImageResource(img);
TextView textView1 = new TextView(this.mActivity);
textView1.setText("Touch sensor");
textView1.setTextSize(13);
textView1.setTextColor(mColor.GRAY);
textView1.setPadding(0, 50, 0,0);
textView1.setLayoutParams(param3);
Button myButton = new Button(this.mActivity);
myButton.setText("Cancel");
myButton.setPadding(0, 0, 0,0);
myButton.setLayoutParams(param4);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getDialog().dismiss();
}
});
relativeLayout.addView(textView);
relativeLayout.addView(image);
relativeLayout.addView(textView1);
relativeLayout.addView(myButton);
framelayout.addView(relativeLayout);
return framelayout;
}
@Override
public void onResume() {
super.onResume();
if(mCryptoObject.toString() == null){
System.out.println("inside if");
return;
}else{
mFingerprintUiHelper.startListening(mCryptoObject);
}
}
public void setStage(Stage stage) {
mStage = stage;
}
@Override
public void onPause() {
super.onPause();
mFingerprintUiHelper.stopListening();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mActivity = (MainActivity) activity;
}
/**
* Sets the crypto object to be passed in when authenticating with fingerprint.
*/
public void setCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
mCryptoObject = cryptoObject;
}
public void onAuthenticated() {
// Callback from FingerprintUiHelper. Let the activity know that authentication was
// successful.
mActivity.onPurchased(true /* withFingerprint */);
dismiss();
}
@ Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// TODO Auto-generated method stub
return false;
}
public enum Stage {
FINGERPRINT,
NEW_FINGERPRINT_ENROLLED,
PASSWORD
}
}
when the control comes to this line mFingerprintUiHelper.startListening(mCryptoObject); it throws the null pointer exception.
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.