Hirdetés

Új hozzászólás Aktív témák

  • doc

    nagyúr

    valaki esetleg tudna segiteni AdMob ugyben?

    Van egy C++ -ban megirt appom, es szeretnem valahogy odabiggyeszteni az AdMob reklamot.
    Addig sikerult eljutnom, hogy a fokepernyom helyett egy fekete kepernyot kapok, alul egy pici szurke teglalappal a reklam helyen. Sajna Javaban nagyon gyer vagyok, szoval eleg nehezen haladok.

    Eddig ennyim van:

    C++:

    #ifdef __ANDROID__
    #include "jni.h"
    #include "android_native_app_glue.h"

    void showAds()
    {
    JNIEnv *env = static_cast<JNIEnv*>(SDL_AndroidGetJNIEnv());
    jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
    jclass cls = env->GetObjectClass(activity);
    jclass localcls = reinterpret_cast<jclass>(env->NewGlobalRef(cls));
    jmethodID showAds = env->GetStaticMethodID(localcls, "showAdPopup", "()V");
    env->CallStaticVoidMethod(localcls, showAds);
    }

    #endif

    Java:

    // Our popup window, you will call it from your C/C++ code later
    public static void showAdPopup()
    {
    //if(adsinited)
    //{
    // return;
    //}
    if(adView!=null) {
    _activity.runOnUiThread(new Runnable() {
    @Override
    public void run() {
    adsinited = true;
    // Out popup window
    popUp = new PopupWindow(_activity);
    // This is the minimum size for AdMob, we need to set this in case our target device run at 320x480 resolution (Otherwise no ad will be shown, see the padding kill below)
    popUp.setWidth(320);
    popUp.setHeight(50);
    popUp.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    popUp.setClippingEnabled(false);
    layout = new LinearLayout(_activity);
    mainLayout = new LinearLayout(_activity);
    // The layout system for the PopupWindow will kill some pixels due to margins/paddings etc… (No way to remove it), so padd it to adjust
    layout.setPadding(-5, -5, -5, -5);
    MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 0, 0);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(adView, params);
    popUp.setContentView(layout);
    _activity.setContentView(mainLayout, params);
    AdRequest adRequest = new AdRequest();
    // Enable this if your are testing AdMob, otherwise you'll risk to be banned!
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
    _activity.adView.loadAd(adRequest);
    // Show our popup window
    popUp.showAtLocation(mainLayout, Gravity.BOTTOM, 0, 0);
    popUp.update();
    }});
    }
    }

Új hozzászólás Aktív témák