-2

I want to install GDPR SDK in my Android Studio project, but I have an error message in MainActivity when I call requestConsentInfoUpdate() on an instance of ConsentInformation.

public class MainActivity extends AppCompatActivity {

    InterstitialAd mInterstitialAd;
    private InterstitialAd interstitial;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /////////////////////////////////////////////////// CONSENT GDPR

        ConsentInformation consentInformation = ConsentInformation.getInstance(context);
        String[] publisherIds = {"pub-6026672754365474"};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
            @Override
            public void onConsentInfoUpdated(ConsentStatus consentStatus) {
                // User's consent status successfully updated.
            }

            @Override
            public void onFailedToUpdateConsentInfo(String errorDescription) {
                // User's consent status failed to update.
            }
        });

I have error on getInstance(context);:

Error : cannot resolve symbol context
Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

0

You can't use context. replace that with getApplicationContext() or this :

ConsentInformation consentInformation = ConsentInformation.getInstance(this);
// or    
ConsentInformation consentInformation = ConsentInformation.getInstance(getApplicationContext());
Arash Hatami
  • 5,297
  • 5
  • 39
  • 59