Skip to content Skip to sidebar Skip to footer

Incompatible Types: Cannot Be Converted To Context

I am and getting an error when trying to modify code to handle documents in Android Nougat. incompatible types: cannot be converted to Context This is my code documentViewHo

Solution 1:

publicclassMessageAdapterextendsBaseAdapter {
private Context context;

publicMessageAdapter(Context context) {
    this.context = context;
}

use that context(instead of MessageAdapter.this) in Uri

Uripath= FileProvider.getUriForFile(context ,BuildConfig.APPLICATION_ID + ".provider",document);

Solution 2:

MessageAdapter is not a subclass of Context. Usually, for what you are doing (starting an activity, presumably), you have access to the Activity that you are in, and that is the Context to use here.

Post a Comment for "Incompatible Types: Cannot Be Converted To Context"