I have set OnClickListener
, on drawableRight
in edittext
for phone numbers so, can you help to open Call Log when I press the button, my phone's call log box opens and I select one of the recently used numbers for the edittext box. so, now What to write for the action for onclicklistener
?
I have written code in MainActivity.java as:
public class MainActivity extends AppCompatActivity {
CountryCodePicker ccp;
TextInputEditText number;
@SuppressLint({"ResourceType", "ClickableViewAccessibility"})
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ccp = findViewById(R.id.ccp);
number = (TextInputEditText) findViewById(R.id.Phone_Number);
number.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= (number.getRight() - number.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
// your action here
CallsProvider callsProvider = new CallsProvider (getApplicationContext());
callsProvider.getCalls();
}
}
return false;
}
});
}
}