1

我们正在开发一个使用 admob 进行广告的应用程序。

现在我们想通过adMob集成tapit sdk。我从这里下载了源代码

https://github.com/tapit/TapIt-Android-SDK-Source

但我没有成功整合全屏广告、广告提醒。

我进行了很多搜索,但没有找到任何合适的文档或教程来集成它。

所以帮我整合一下。

4

2 回答 2

1

首先,您想从以下位置构建您的区域 ID 和中介 ID:

http://tapit.com/google

然后在您的项目 xml 文件中添加 Tapit 视图

<com.tapit.adview.AdView
        android:id="@+id/bannerAd"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/googLayout"
        android:layout_marginTop="23dp"
        zone="" />

然后在 java 代码活动中,您需要声明所有区域 id 并实现以下方法。

public final static String BANNER_ZONE_ID = "7979";
    public final static String VIDEO_ZONE_ID = "7981";
    public final static String MED_RECT_ZONE_ID = "7982";
    public final static String INTRS_ZONE_ID = "7983";
    public final static String ADPROMPT_ZONE_ID = "7984";

//对于横幅

private void setupBannerAd(){
        bannerAd = (AdView)findViewById(R.id.bannerAd);
        bannerAd.setBackgroundColor(0);

        // the remainder of this method is optional...

//        Map<String, String> params = new HashMap<String, String>();
//        params.put("mode", "test");
//        bannerAd.setCustomParameters(params);

        // if you're interested in being updated with banner ad lifecycle events, register a listener
        bannerAd.setOnAdDownload(new OnAdDownload() {
            @Override
            public void begin(AdViewCore adView){
                // Called just before an ad request is made
                Log.d("TapItTest", "Requesting banner ad");
                Toast.makeText(getApplicationContext(), "Requesting banner ad", Toast.LENGTH_SHORT).show();
                bannerAd.setBackgroundColor(0);
            }

            @Override
            public void end(AdViewCore adView){
                // Called after an ad is successfully loaded... show ad
                Log.d("TapItTest", "Banner ad successfully loaded");
                Toast.makeText(getApplicationContext(), "Banner ad successfully loaded", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void error(AdViewCore adView, String error){
                // Called when bannerAd fails to load an ad... hide ad
                Toast.makeText(getApplicationContext(), "Failed to load banner: " + error, Toast.LENGTH_LONG).show();
                Log.d("TapItTest", "Banner ad failed to load: " + error);
            }

            @Override
            public void clicked(AdViewCore adView){
                Log.d("TapItTest", "Ad clicked");
                Toast.makeText(getApplicationContext(), "Ad clicked", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void willPresentFullScreen(AdViewCore adView){
                Log.d("TapItTest", "willPresentFullScreen");
                Toast.makeText(getApplicationContext(), "willPresentFullScreen", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void didPresentFullScreen(AdViewCore adView){
                Log.d("TapItTest", "didPresentFullScreen");
                Toast.makeText(getApplicationContext(), "didPresentFullScreen", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void willDismissFullScreen(AdViewCore adView){
                Log.d("TapItTest", "willDismissFullScreen");
                Toast.makeText(getApplicationContext(), "willDismissFullScreen", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void willLeaveApplication(AdViewCore adView){
                Log.d("TapItTest", "Leaving Application!");
                Toast.makeText(getApplicationContext(), "Leaving Application!", Toast.LENGTH_SHORT).show();
            }
        });
    }

//用于提示

    /**
     * AdPrompt init code with anonymous listener
     */
    public void initAdPrompt() {
        adPrompt = new AdPrompt(this, ADPROMPT_ZONE_ID);

        // the remainder of this method is optional...

        // send optional params to the AdPrompt
//        Map<String, String> params = new HashMap<String, String>();
//        params.put("mode", "test");
//        adPrompt.setCustomParameters(params);

        // if you're interested in being updated with AdPrompt lifecycle events, register a listener
        adPrompt.setListener(new AdPrompt.AdPromptCallbackListener() {

            @Override
            public void adPromptError(AdPrompt adPrompt, String error){
                Log.d("TapItTest", "AdPrompt failed to load: " + error);
                Toast.makeText(getApplicationContext(), "AdPrompt failed to load: " + error, Toast.LENGTH_LONG).show();
                MainActivity.this.adPrompt = null;
            }

            @Override
            public void adPromptLoaded(AdPrompt adPrompt){
                Log.d("TapItTest", "AdPrompt loaded");
                Toast.makeText(getApplicationContext(), "AdPrompt loaded", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void adPromptDisplayed(AdPrompt adPrompt){
                Log.d("TapItTest", "AdPrompt has been shown");
            }

            @Override
            public void adPromptClosed(AdPrompt adPrompt, boolean didAccept){
                Log.d("TapItTest", "AdPrompt was closed using the " + (didAccept ? "CallToAction" : "Decline") + " button");
                MainActivity.this.adPrompt = null;
            }
        });
    }


//adprompt
    /**
     * Pre-load the AdPrompt... We'll show it later
     */
    public void preloadAdPrompt() {
        Log.d("TapItTest", "Loading AdPrompt");
        initAdPrompt();
        adPrompt.load();
    }

    /**
     * Show the AdPrompt.  If it hasn't been pre-loaded, init before showing
     */
    public void fireAdPrompt() {
        Log.d("TapItTest", "showing AdPrompt");
        if(adPrompt == null) {
            // AdPrompt wasn't pre-loaded.  We'll instantiate and show at the same time...
            initAdPrompt();
        }
        adPrompt.showAdPrompt();
    }

//用于加载插页式广告

    /**
     * Load up an interstitial with listener example
     */
    public void preloadInterstitial() {
        interstitialAd = new AdInterstitialView(this, INTRS_ZONE_ID);

        // Optionally specify custom params
        // un-comment to enable test mode
//        Map<String, String> params = new HashMap<String, String>();
//        params.put("mode", "test");
//        interstitialAd.setCustomParameters(params);

        // Optionally register a listener to get ad lifecycle notifications.
        interstitialAd.setOnInterstitialAdDownload(new OnInterstitialAdDownload() {
            @Override
            public void willLoad(AdViewCore adView){
                // interstitial is about to load
                Log.d("TapItTest", "WillLoad");
                Toast.makeText(getApplicationContext(), "WillLoad", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void ready(AdViewCore adView){
                // interstitial is loaded and ready for display
                Log.d("TapItTest", "ready!");
                showButton.setEnabled(true);
                Toast.makeText(getApplicationContext(), "ready!", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void willOpen(AdViewCore adView){
                // interstitial is about to cover the screen. minimize your app footprint
                Log.d("TapItTest", "WillOpen");
                Toast.makeText(getApplicationContext(), "WillOpen", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void didClose(AdViewCore adView){
                // interstitial is no longer covering the screen
                Log.d("TapItTest", "didClose");
                Toast.makeText(getApplicationContext(), "didClose", Toast.LENGTH_SHORT).show();
                destroyInterstitial();

                loadButton.setEnabled(true);
                showButton.setEnabled(false);
            }

            @Override
            public void error(AdViewCore adView, String error){
                Log.d("TapItTest", "Failed to load interstitial: " + error);
                Toast.makeText(getApplicationContext(), "Failed to load interstitial: " + error, Toast.LENGTH_LONG).show();

                showButton.setEnabled(false);
                loadButton.setEnabled(true);
            }

            @Override
            public void clicked(AdViewCore adView){
                Log.d("TapItTest", "Ad clicked");
                Toast.makeText(getApplicationContext(), "Ad clicked", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void willLeaveApplication(AdViewCore adView){
                Log.d("TapItTest", "Leaving Application!");
                Toast.makeText(getApplicationContext(), "Leaving Application!", Toast.LENGTH_SHORT).show();
            }
        });

        // fire off the ad request.
        interstitialAd.load();
    }


    /**
     * Wire up the buttons...
     */
    public void setupButtons() {
        loadButton = (Button)findViewById(R.id.loadInterstitialButton);
        loadButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View button){
                preloadInterstitial();
                loadButton.setEnabled(false);
            }
        });
        showButton = (Button)findViewById(R.id.showInterstitialButton);
        showButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View button) {
                interstitialAd.showInterstitial();
            }
        });
        showButton.setEnabled(false);

        final MainActivity me = this;
        ((Button)findViewById(R.id.loadAdPromptButton)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view){
                me.preloadAdPrompt();
            }
        });

        ((Button)findViewById(R.id.showAdPromptButton)).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v){
                me.fireAdPrompt();
            }
        });

    }
于 2012-11-29T12:55:18.990 回答
0

对于 Tapit,您需要在Android-mainfest.xml文件中添加以下权限

-->

和两个活动

<activity
            android:name="com.tapit.adview.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation" />
        <activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
于 2012-11-30T04:38:40.280 回答