开发者

are ad unit id and ppublisher id same?

I am new to android applications dev . I am preparing an application which should display Admob at the bottom, for that i crated an ac in Admob and got a publisher id and placed in my code.

But client gave me integration details as

adunit ID -

xxxx (five digit number)

Here is the app ID:

0axxxxxb-xxdx-xxxa-xxxx-cxxbxxxxxaxx (here x's are numbers)

my question开发者_如何学Go is, are both adunit id and publisher id same? If so I have publisher id with 15 dig number...but adunit id is only 5 dig what should i do now?


I would say it's the same thing based on the official Admob's documentations

The five lines of code it takes to add a banner:

  • Import com.google.ads.*
  • Declare an AdView instance
  • Create it, specifying a unit ID—your AdMob publisher ID
  • Add the view to the UI
  • Load it with an ad

Clarify with your client.


No, PublisherId is unique account id whereas ad Unit id is id per application.


I get the adUnitId using this method running from the onCreate() method from my app.

public void getIdThread() {
    new Thread(new Runnable() {         
        @Override
        public void run() {
    // Do not call this function from the main thread. Otherwise, 
    // an IllegalStateException will be thrown.
    Info adInfo = null;
    try {
        adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
        Log.d("AD_INFO", "adInfo :: " +adInfo);
    } catch (IOException e) {
        // Unrecoverable error connecting to Google Play services (e.g.,
        // the old version of the service doesn't support getting AdvertisingId).

    } catch (GooglePlayServicesNotAvailableException e) {
        // Google Play services is not available entirely.
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (GooglePlayServicesRepairableException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    final String adUnitId = adInfo.getId();
    final boolean isLAT = adInfo.isLimitAdTrackingEnabled();
    Log.d("AD_INFO", "adUnitId :: " +adUnitId);
    Log.d("AD_INFO", "isLAT :: " +isLAT);
        }
    }).start();
}

and this is the format of an adUnitId:

da123eb7-19a9-43aa-a98b-9ae24de45f25
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜