@Override
public void onClick(View v) {
Dexter.withActivity(this)
.withPermission(Manifest.permission.CALL_PHONE)
.withListener(new PermissionListener() {
@Override public void onPermissionGranted(PermissionGrantedResponse response) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
mcontext.startActivity(callIntent);}
@Override public void onPermissionDenied(PermissionDeniedResponse response) {/* ... */}
@Override public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {/* ... */}
}).check();
}
The context 'this' shows as an error. And also the line of code that calls someone is still showing as an error even after i put it in the OnPermissionGranted() method. What should i change to make this work?
The link for the dexter library is given below:
I used Activity act = (Activity)(holder.call.getContext());
to get the activity and then used act inside Dexter.withActivity()
. None of the other solutions worked. I had to get the context through one of the views and then convert it into an activity as shown above.