Closed achinverma closed 6 years ago
i will post my code in my activity
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pattern_view_status"
android:layout_margin="20dp"
android:orientation="vertical">
<com.guardanis.applock.pin.PINInputView
android:id="@+id/pin__input_view"
android:layout_width="fill_parent"
android:layout_height="@dimen/pin__default_item_size" />
</LinearLayout>
public class PinLockActivity extends AppCompatActivity {
private Toolbar mToolbarView;
PINInputView pinInputView;
protected PINInputController inputController;
private int inputViewsCount = 4;
private ActivityLockingHelper lockingHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pin_lock);
Slidr.attach(this);
lockingHelper = new ActivityLockingHelper(this, null);
pinInputView = (PINInputView) findViewById(R.id.pin__input_view);
mToolbarView = (Toolbar) findViewById(R.id.choosePintoolbar);
mToolbarView.setTitle("");
setSupportActionBar(mToolbarView);
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
inputController = new PINInputController(pinInputView, null);
inputController.setInputEventListener(new PINInputController.InputEventListener() {
@Override
public void onInputEntered(String input) {
Log.e("setInputEventListener",""+input);
if(input.length() < inputViewsCount) {
}else{
}
}
});
}
@Override
public boolean onOptionsItemSelected(final MenuItem menu) {
switch (menu.getItemId()) {
case android.R.id.home:
this.finish();
return true;
default:
return super.onOptionsItemSelected(menu);
}
}
}
I don't see anything that would cause it to crash. The line your Exception is referencing is wrapped in a try/catch that prints the error (which would only ever be the NullPointerException you're seeing, which is should be generally safe to ignore if it happens).
Are you experiencing a crash, is it not working correctly, or is this just in your logs and you're concerned?
If it's one of the former two, then try explicitly calling setInputNumbersCount(inputViewsCount)
on your inputController
before adding the event listener. It looks like without the Intent overrides from the base classes I built, the default input count may not line up with yours.
@mattsilber i am not getting any crash but when user enter the pin i am not able get output in
inputController.setInputEventListener(new PINInputController.InputEventListener() {
@Override
public void onInputEntered(String input) {
Log.e("setInputEventListener",""+input);
}
});
i mean my this line is not printing any value when user enters the pin in PINInputView Log.e("setInputEventListener",""+input);
The callback is being triggered, but the data isn't being passed back? And you've tested this with full input entered?
Can you also check if the base helper classes are working for you, to see if this is an issue with the library, or an issue with the implementation:
new CreateLockDialogBuilder(Activity,
new LockCreationListener(){
public void onLockCanceled(){ } // Dialog was closed without entry
public void onLockSuccessful(){
ActionLockingHelper.unlockIfRequired(Activity, new UnlockEventListener(){
public void onCanceled(){ } // Dialog was closed without entry
public void onUnlockFailed(String reason){ } // Not called with default Dialog, instead is handled internally
public void onUnlockSuccessful(){
Log.d("AppLock", "Unlock successful");
}
});
}
})
.show();
If you just run that blob within your app, that should open the create dialog, and, on success, open the unlock dialog. If unlocking is successful, then there may be something weird going on with your setup, but this should point us in the right direction.
Closed since it's almost been 2 years and I'm about to push a large update...
Hi , i am using this library for pin lock in my app, but i am getting error , please find the below