3

こんにちは、android cocos2d を使用して開発した Android ゲーム アプリを持っています。admob を統合する必要があります。次のコードを含めましたが、バナー広告が表示されません。ありがとうございました。

public class MainActivity extends Activity {
private CCGLSurfaceView mGLSurfaceView;
private boolean isCreated = false;
public static FrameLayout m_rootLayout;
AdView adView;

// This is used to display Toast messages and is not necessary for your app
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (!isCreated) {
        isCreated = true;
    } else {
        return;
    }

    super.onCreate(savedInstanceState);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    try{
            LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams(
            getWindowManager().getDefaultDisplay().getWidth(),
            getWindowManager().getDefaultDisplay().getHeight()+getWindowManager().getDefaultDisplay().getHeight()-50);

            adView = new AdView(this, AdSize.BANNER, "admob id");

            AdRequest request = new AdRequest();
            adView.loadAd(request);
            // Adding full screen container
            addContentView(adView, adParams);
            }catch (Exception e) {
            FlurryAgent.logEvent("ADMOB ERROR: "+e);
            }



    mGLSurfaceView = new CCGLSurfaceView(this);
    setContentView(mGLSurfaceView);


    CCDirector.sharedDirector().attachInView(mGLSurfaceView);

    getScaledCoordinate();

    Global.assetManager = getAssets();
    Global.context = this;
    Global.loadUserInfo();
    CCScene scene = CCScene.node();
    scene.addChild(new SplashScene(), -1);

    CCDirector.sharedDirector().runWithScene(scene);


    //-------------IAP-----------------------
    Log.d(TAG1, "Creating IAB helper.");
        mHelper = new IabHelper(this, base64EncodedPublicKey);
        mHelper.enableDebugLogging(true);
        Log.d(TAG1, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                Log.d(TAG, "Setup finished.");

                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    complain("Problem setting up in-app billing: " + result);
                    return;
                }

                // Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
                Log.d(TAG, "Setup successful. Querying inventory.");
                mHelper.queryInventoryAsync(mGotInventoryListener);
            }
        });


        Global.myActivity=this;
}

マニフェスト

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.game.puzzlegame"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.game.puzzlegame.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.revmob.ads.fullscreen.FullscreenActivity"
        android:configChanges="keyboardHidden|orientation" >
    </activity>

    <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"></activity>
</application>

4

4 に答える 4

0

正しい ID を含め、アプリに対応する権限があることを確認してください。

さらに、広告のレンダリングがどのように行われているかを実際に表示する ADListener を実装するとよいでしょう。

また、広告をクエリするテスト モードを設定することも忘れないでください。

于 2013-04-26T12:16:43.783 に答える