I want to implement the MPIN functionality in my mobile banking application..I have six edittext using text-watcher I'm doing this function.
Once i completed the 6 fields how to check whether that pin is correct or not automatically and how to show alert. If Pin is correct how to move next screen automatically.
I stored the pin in sharedpreference using this value how to check condition.Where I have to check this condition. Please help me.
This is my code:
public class AboutUsActivity extends AppCompatActivity {
EditText t1,t2,t3,t4,t5,t6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about_us);
t1=(EditText) findViewById(R.id.first);
t2=(EditText) findViewById(R.id.second);
t3=(EditText) findViewById(R.id.third);
t4=(EditText) findViewById(R.id.fourth);
t5=(EditText) findViewById(R.id.fifth);
t6=(EditText) findViewById(R.id.sixth);
t1.addTextChangedListener(new GenericTextWatcher(t1));
t2.addTextChangedListener(new GenericTextWatcher(t2));
t3.addTextChangedListener(new GenericTextWatcher(t3));
t4.addTextChangedListener(new GenericTextWatcher(t4));
t5.addTextChangedListener(new GenericTextWatcher(t5));
t6.addTextChangedListener(new GenericTextWatcher(t6));
}
public class GenericTextWatcher implements TextWatcher
{
private View view;
private GenericTextWatcher(View view)
{
this.view = view;
}
@Override
public void afterTextChanged(Editable editable) {
// TODO Auto-generated method stub
Log.i("AA","aftertext--");
String text = editable.toString();
switch(view.getId())
{
case R.id.first:
if(text.length()==1)
t2.requestFocus();
if(text.length()==0)
t1.requestFocus();
break;
case R.id.second:
if(text.length()==1)
t3.requestFocus();
if(text.length()==0)
t1.requestFocus();
break;
case R.id.third:
if(text.length()==1)
t4.requestFocus();
if(text.length()==0)
t2.requestFocus();
break;
case R.id.fourth:
if(text.length()==1)
t5.requestFocus();
if(text.length()==0)
t3.requestFocus();
break;
case R.id.fifth:
if(text.length()==1)
t6.requestFocus();
if(text.length()==0)
t4.requestFocus();
break;
case R.id.sixth:
if(text.length()==0)
t5.requestFocus();
break;
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
Log.i("AA","beforetext--");
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{
// TODO Auto-generated method stub
Log.i("AA","textchanged--");
}
}
}