-1

This is Rewarded video ads code

public class YourApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();
    // Initialize the Audience Network SDK
    AudienceNetworkAds.initialize(this);       
}
...
}

Rewarded Video Ads in main activity

in fragment AudienceNetworkAds.initialize(this); not support

  • You forgot to ask question here .. Whats the Problem you are having with the code ? – ADM Jun 01 '19 at 04:07
  • See Duplicate [Using context in a fragment](https://stackoverflow.com/questions/8215308/using-context-in-a-fragment). – ADM Jun 01 '19 at 04:18

1 Answers1

0

You don't need to initialize it in every Activity/Fragment AudienceNetworkAds.initialize(this);

You can initialize it once and it will work everywhere.

From the official guide

Before creating an ad object and loading ads, you should initialize the Audience Network SDK. It is recommended to do this at app launch.

However if you still want to do in fragment. change context this to getActivity() AudienceNetworkAds.initialize(getActivity());

shb
  • 5,957
  • 2
  • 15
  • 32