I am creating a call application i created an adapter for Recycler view on requesting CALL_PHONE there is showing the error
E/AndroidRuntime: FATAL EXCEPTION: main Process: in.welcomeyou.merchant, PID: 14890 java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
@Override
public void onBindViewHolder(EnquiryViewHolder holder, int position) {
Enquiry enquiry = enquiryList.get(position);
holder.domainTextView.setText(enquiry.getDomain());
holder.nameTextView.setText(enquiry.getName());
holder.commentsTextView.setText(enquiry.getComments());
holder.dateTextView.setText(enquiry.getDate());
holder.callBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ActivityCompat.checkSelfPermission(mCtx, CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.CALL_PHONE},
Constants.CALL_PHONE);
return;
}
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123456"));
mCtx.startActivity(intent);
}
});
}