1

我已经为这个问题苦苦挣扎了一段时间,如果有人能帮助我,我将不胜感激。

问题是,当我成功加载airpush“智能墙”时,它会自行“点击”,然后我会立即前往广告将你带到的任何地方。在广告完成加载之前,我可以看到广告加载的图形表示。

我已经多次联系 AP 支持,但无论我做什么,我仍然遇到同样的问题。

问题似乎是智能墙在错误的线程上运行,我正在使用 UIThread 处理程序来处理其他内容并且它工作正常(leadbolt interstitials、alertdialogs 和其他原生 android 内容)。

我尝试过的事情:

异步任务

    @Override
public void showAP() {
    uiThread.post(new Runnable(){
        public void run(){
            new Async().execute();
        }
    });
}

private class Async extends AsyncTask<String, Integer, String[]>{

    @Override
      protected void onPreExecute() {
       super.onPreExecute();
      }

    @Override
    protected String[] doInBackground(String... params) {
        if(apSmartWall == null)
            apSmartWall = new ApSmartWall(MainActivity.this, adCallbackListener);
        apSmartWall.startSmartWallAd();
        return null;
    }

    @Override
      protected void onProgressUpdate(Integer... values) {
       super.onProgressUpdate(values);

      }

    @Override
      protected void onPostExecute(String[] result) {
       super.onPostExecute(result);
      }

}

处理程序

 @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    apSmartWall = new ApSmartWall(MainActivity.this, adCallbackListener);

    // Create the layout
    layout = new RelativeLayout(this);

    // Do the stuff that initialize() would do for you
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    // Create the libgdx View
    gameView = initializeForView(new Game(this), true);

    // Add the libgdx view
    layout.addView(gameView);

    context = this;

    uiThread = new Handler(); 

    ... (adding another view for mopub here, but removing this doesn´t change anything)

    // Hook it all up
    setContentView(layout);

}
 @Override
public void showAP() {
    uiThread.post(new Runnable(){
        public void run(){
            apSmartWall.startSmartWallAd();
        }
    });
}

libGDX 线程的东西:https ://code.google.com/p/libgdx/wiki/TheArchitecture#The_Graphics_Module

我还尝试使用内置处理程序方法 AndroidApplication.runOnUiThread() 的 libGDX,但这也不起作用。我对原生 Android 毫无经验,所以我可能做错了什么。但就像我说的,它适用于在 UI 线程上运行的其他东西,例如这很好用:

@Override
public void resumeAds() {
    uiThread.post(new Runnable(){

        public void run() {
            moPubView = new MoPubView(context);
            // non-tablet
            if(width >= 728)
                moPubView.setAdUnitId(TABLET_SIZE);
            else
                moPubView.setAdUnitId(PHONE_SIZE);
            moPubView.loadAd();

            RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

            layout.addView(moPubView, adParams);
        }

    });
}

AndroidManifest.xml 空推的东西

<meta-data android:name="com.package.APPID" android:value="appid" />
<meta-data android:name="com.package.APIKEY" android:value="android*key"/>

<activity android:exported="false" android:name="com.package.SmartWallActivity"
 android:configChanges="orientation|screenSize"
 android:theme="@android:style/Theme.Translucent" />

<activity android:name="com.package.BrowserActivity"
 android:configChanges="orientation|screenSize" />
4

0 回答 0