1

我在将 mobfox 代码实现到我的应用程序时遇到问题。

它的 502 Bad Gateway 服务器充当网关或代理,并从上游服务器收到无效响应。我认为的错误在于: public void onInterstitialFailed(InterstitialAd intersitial, Exception e) { 我认为:代码无法从 mobfox 下载广告...

我的 LogCat 错误:

03-05 19:08:47.311: E/TINGZ(20967): [main(1)] dbg: ### Init in TingzLibrary ###
03-05 19:08:47.331: E/TINGZ(20967): [main(1)] dbg: ### Finihsed Init in TingzLibrary ###
03-05 19:08:47.511: E/Volley(20967): [3383] BasicNetwork.performRequest: Unexpected response code 502 for https://api.tingz.me/ting-server-ws/authentication/isRunSDK?device_id=f25804b1a6cd70d4
03-05 19:08:47.581: E/libEGL(20967): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
03-05 19:08:47.621: E/TINGZ(20967): [main(1)] User f25804b1a6cd70d4 had problems checking SDK with the following status code com.android.volley.ServerError
03-05 19:08:49.471: E/(20967): g2d stretchFimgApi_v5 function does not exist
03-05 19:08:49.471: E/(20967): [JM] stretchFimgApi might be v4.
03-05 19:08:52.671: E/Volley(20967): [3384] BasicNetwork.performRequest: Unexpected response code 502 for https://api.tingz.me/ting-server-ws/authentication/isRunSDK?device_id=f25804b1a6cd70d4
03-05 19:08:52.671: E/TINGZ(20967): [main(1)] User f25804b1a6cd70d4 had problems checking SDK with the following status code com.android.volley.ServerError
03-05 19:08:58.371: E/Volley(20967): [3385] BasicNetwork.performRequest: Unexpected response code 502 for https://api.tingz.me/ting-server-ws/authentication/isRunSDK?device_id=f25804b1a6cd70d4
03-05 19:08:58.371: E/TINGZ(20967): [main(1)] User f25804b1a6cd70d4 had problems checking SDK with the following status code com.android.volley.ServerError
03-05 19:09:03.431: E/Volley(20967): [3386] BasicNetwork.performRequest: Unexpected response code 502 for https://api.tingz.me/ting-server-ws/authentication/isRunSDK?device_id=f25804b1a6cd70d4
03-05 19:09:03.431: E/TINGZ(20967): [main(1)] User f25804b1a6cd70d4 had problems checking SDK with the following status code com.android.volley.ServerError
03-05 19:09:08.501: E/Volley(20967): [3383] BasicNetwork.performRequest: Unexpected response code 502 for https://api.tingz.me/ting-server-ws/authentication/isRunSDK?device_id=f25804b1a6cd70d4
03-05 19:09:08.501: E/TINGZ(20967): [main(1)] User f25804b1a6cd70d4 had problems checking SDK with the following status code com.android.volley.ServerError
[...]

这是我的 Main.java:

package go.launcherex.theme.forest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
import android.widget.Toast;
import com.mobfox.sdk.interstitialads.InterstitialAd;
import com.mobfox.sdk.interstitialads.InterstitialAdListener;

@SuppressLint("NewApi")
public class Main extends FragmentActivity implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener, View.OnTouchListener{

    public class PagerAdapter extends FragmentPagerAdapter {

        private List<Fragment> fragments;
        /**
         * @param fm
         * @param fragments
         */
        public PagerAdapter(FragmentManager fm, List<Fragment> fragments) {
            super(fm);
            this.fragments = fragments;
        }
        /* (non-Javadoc)
         * @see android.support.v4.app.FragmentPagerAdapter#getItem(int)
         */
        @Override
        public Fragment getItem(int position) {
            return this.fragments.get(position);
        }

        /* (non-Javadoc)
         * @see android.support.v4.view.PagerAdapter#getCount()
         */
        @Override
        public int getCount() {
            return this.fragments.size();
        }
    }

    private class TabInfo {
        private String tag;
        private Class<?> clss;
        private Bundle args;
        private Fragment fragment;
        TabInfo(String tag, Class<?> clazz, Bundle args) {
            this.tag = tag;
            this.clss = clazz;
            this.args = args;
        }

   }

    class TabFactory implements TabContentFactory {

        private final Context mContext;

        /**
         * @param context
         */
        public TabFactory(Context context) {
            mContext = context;
        }

        /** (non-Javadoc)
         * @see android.widget.TabHost.TabContentFactory#createTabContent(java.lang.String)
         */
        @Override
        public View createTabContent(String tag) {
            View v = new View(mContext);
            v.setMinimumWidth(0);
            v.setMinimumHeight(0);
            return v;
        }

    }

    private TabHost mTabHost;
    private ViewPager mViewPager;
    private HashMap<String, TabInfo> mapTabInfo = new HashMap<String, TabInfo>();
    private PagerAdapter mPagerAdapter;
    private PlayTab playTab;

    InterstitialAd interstitial;
    InterstitialAdListener listener;
   private Handler handler = new Handler();
   private Runnable timerRunnable = new Runnable() {  
        @Override
        public void run() {
            onTimer();
        }

    };


    /** Called when the activity is first created. */


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


        interstitial = new InterstitialAd(this);

        final Activity self = this;

        InterstitialAdListener listener = new InterstitialAdListener() {
            @Override
            public void onInterstitialLoaded(InterstitialAd intersitial) {

                interstitial.show();
                Toast.makeText(self, "POSZLA", Toast.LENGTH_SHORT).show();


            }
            @Override
            public void onInterstitialClosed(InterstitialAd interstitial) {


            }
            @Override
            public void onInterstitialFinished() {

                   Toast.makeText(self, "finished", Toast.LENGTH_SHORT).show();

            }
            @Override
            public void onInterstitialClicked(InterstitialAd interstitial) {

            }
            @Override
            public void onInterstitialShown(InterstitialAd interstitial) {
                  Toast.makeText(self, "pokazz", Toast.LENGTH_SHORT).show();

                  interstitial.setInventoryHash("267d72ac3f77a3f447b32cf7ebf20673");
                  interstitial.load();

            }
            @Override
            public void onInterstitialFailed(InterstitialAd intersitial, Exception e) {
                  Toast.makeText(self, "dupaaaa", Toast.LENGTH_SHORT).show();

            }

        };

        interstitial.setListener(listener);
        interstitial.setInventoryHash("267d72ac3f77a3f447b32cf7ebf20673");
        interstitial.load();

            this.initialiseTabHost(savedInstanceState);
            // Intialise ViewPager
            this.intialiseViewPager();
            if (savedInstanceState != null) {
                mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); //set the tab as per the saved state



        }

    }


public void stopTimer(){
        handler.removeCallbacks(timerRunnable);

    }

    public void restartTimer(){
        stopTimer();
        handler.postDelayed(timerRunnable, 25*1000);


         interstitial.load();
    }



    public void onTimer(){



         interstitial.show();
        }

    static int counter = 0;



    public void createInterstitialAd1(){

      if(counter <= 100){


         counter++; 



      }

    }
 //permission dialog for marshmello and above


    @Override
    public void onDestroy() {

             stopTimer();
        super.onDestroy();





    }

    @Override
    public void onPause() {
            stopTimer();
        super.onPause();
        interstitial.onPause();

    }

    @Override
    public void onResume() {
        super.onResume();
        interstitial.onResume();
        playTab.onResume();
          restartTimer();


    }


    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putString("tab", mTabHost.getCurrentTabTag()); //save the tab selected
        super.onSaveInstanceState(outState);

    }

    private void intialiseViewPager() {

        List<Fragment> fragments = new Vector<Fragment>();
        fragments.add(Fragment.instantiate(this, MainTab.class.getName()));
        playTab = (PlayTab) Fragment.instantiate(this, PlayTab.class.getName());
        fragments.add(playTab);
        this.mPagerAdapter  = new PagerAdapter(super.getSupportFragmentManager(), fragments);
        //
        this.mViewPager = (ViewPager)super.findViewById(R.id.viewpager);
        this.mViewPager.setAdapter(this.mPagerAdapter);
        this.mViewPager.setOnPageChangeListener(this);
    }

    /**
     * Initialise the Tab Host
     */


    private void initialiseTabHost(Bundle args) {
        mTabHost = (TabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup();
        TabInfo tabInfo = null;
        String tab1_name = getResources().getString(R.string.tab1_name);
        String tab2_name = getResources().getString(R.string.tab2_name);
        Main.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec(tab1_name).setIndicator(tab1_name), ( tabInfo = new TabInfo(tab1_name, MainTab.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        Main.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec(tab2_name).setIndicator(tab2_name), ( tabInfo = new TabInfo(tab2_name, PlayTab.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);

        // Default to first tab
        //this.onTabChanged("Tab1");
        //
        mTabHost.setOnTabChangedListener(this);
    }

    /**
     * Add Tab content to the Tabhost
     * @param activity
     * @param tabHost
     * @param tabSpec
     * @param clss
     * @param args
     */
    private static void AddTab(Main activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
        // Attach a Tab view factory to the spec
        tabSpec.setContent(activity.new TabFactory(activity));
        tabHost.addTab(tabSpec);
    }

    /** (non-Javadoc)
     * @see android.widget.TabHost.OnTabChangeListener#onTabChanged(java.lang.String)
     */
    @Override
    public void onTabChanged(String tag) {
        //TabInfo newTab = this.mapTabInfo.get(tag);
        int pos = this.mTabHost.getCurrentTab();
        this.mViewPager.setCurrentItem(pos);

    }

    /* (non-Javadoc)
     * @see android.support.v4.view.ViewPager.OnPageChangeListener#onPageScrolled(int, float, int)
     */
    @Override
    public void onPageScrolled(int position, float positionOffset,
            int positionOffsetPixels) {
        // TODO Auto-generated method stub

    }

    /* (non-Javadoc)
     * @see android.support.v4.view.ViewPager.OnPageChangeListener#onPageSelected(int)
     */
    @Override
    public void onPageSelected(int position) {


        this.mTabHost.setCurrentTab(position);
        final Handler handler = new Handler();




    }

    /* (non-Javadoc)
     * @see android.support.v4.view.ViewPager.OnPageChangeListener#onPageScrollStateChanged(int)
     */
    @Override
    public void onPageScrollStateChanged(int state) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        return false;
    }



   int created = 0;

}
4

0 回答 0