I try to show the ad outside the MainActivity. If I call showAd in this class it works good and show my ad, but when I call this function in my game class via implemented interface I have an error: "Requires the main thread"
MMRequest request = new MMRequest(); ;
MMInterstitial interstitial;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
MMSDK.initialize(this);
interstitial = new MMInterstitial(this);
interstitial.setMMRequest(request);
interstitial.setApid("xxxxxx");
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
RelativeLayout layout = new RelativeLayout(this);
View gameView = initializeForView(new JumpJackieJump(new RequestHandler(), this), cfg);
layout.addView(gameView);
setContentView(layout); }
@Override
public void showAd()
{
interstitial.fetch();
interstitial.setListener(new RequestListenerImpl()
{
@Override
public void requestCompleted(MMAd mmAd)
{
interstitial.display();
}
});