1

I'm using ads system that calls "Appodeal". I'm followed documentation for showing full screen ad "Appodeal.REWARDED VIDEO" type. Appodeal has undetermined response by two types.

First: with full screen unskippable video.

Second: with full screen unskippable video after ending shows another skippable ad.

In second case I have no problem. In first case i have crash with stack trace that shows below.

FATAL EXCEPTION: Timer-0
    Process: chi.tvpoint.badee, PID: 21872
    android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
    at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6462)
    at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:897)
    at android.view.View.requestLayout(View.java:17494)
    at android.view.View.setLayoutParams(View.java:11482)
    at android.view.WindowManagerGlobal.updateViewLayout(WindowManagerGlobal.java:305)
    at android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:91)
    at android.app.Activity.onWindowAttributesChanged(Activity.java:2606)
    at android.view.Window.dispatchWindowAttributesChanged(Window.java:836)
    at com.android.internal.policy.impl.PhoneWindow.dispatchWindowAttributesChanged(PhoneWindow.java:3993)
    at android.view.Window.setFlags(Window.java:813)
    at android.view.Window.clearFlags(Window.java:787)
    at org.nexage.sourcekit.vast.activity.VASTActivity.finishActivity(Unknown Source)
    at org.nexage.sourcekit.vast.activity.VASTActivity.access$500(Unknown Source)
    at org.nexage.sourcekit.vast.activity.VASTActivity$19.run(Unknown Source)
    at java.util.Timer$TimerImpl.run(Timer.java:284)

It is worth noting that I start showing ad from "Dialog" so getting activity reference via getActivity method.

Place where I init ad below.

okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
            Appodeal.initialize(getActivity(), APP_KEY, Appodeal.REWARDED_VIDEO);
            Appodeal.setTesting(true);
            Appodeal.setLogging(true);
            Appodeal.cache(getActivity(), Appodeal.REWARDED_VIDEO);
            Appodeal.setRewardedVideoCallbacks(new RewardedVideoCallbacks() {

                @Override
                public void onRewardedVideoLoaded() {
                    // It doesn't helped.
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                        //    Appodeal.show(getActivity(), Appodeal.REWARDED_VIDEO);
                        }
                    });

                    Appodeal.show(getActivity(), Appodeal.REWARDED_VIDEO);
                }

                @Override public void onRewardedVideoFailedToLoad() {}
                @Override public void onRewardedVideoShown() {}
                @Override public void onRewardedVideoFinished(int i, String s) {}
                @Override public void onRewardedVideoClosed(boolean b) {}
            });
        }
    });
Philipp Buhaievskiy
  • 3,217
  • 2
  • 10
  • 17

0 Answers0