I'm doing an agenda application that has a recycler view with contacts.
I want to add functionality to CALL A CONTACT on swiping right.
I looked at previous questions on StackOverflow, but after doing what has been answered there, Androi Studio still brings me an error -> Code requires permission which can be rejected by the user...
//CALL A CONTACT ON SWIPE RIGHT
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT ) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
//contactViewModel.delete(contactAdapter.getContactAt(viewHolder.getAdapterPosition()));
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + contactAdapter.getContactAt(viewHolder.getAdapterPosition()).getPhone_number()));
startActivity(callIntent);
}
}).attachToRecyclerView(recyclerView);
How can I manage to fix that, I guess I need a few more lines of code.
Worth to mention that I have added the
<uses-permission android:name="android.permission.CALL_PHONE"/>
inside of AndroidManifest.XML