diff --git a/samples/training/ads-and-ux/AndroidManifest.xml b/samples/training/ads-and-ux/AndroidManifest.xml
new file mode 100644
index 000000000..30032f202
--- /dev/null
+++ b/samples/training/ads-and-ux/AndroidManifest.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/ReadMe.txt b/samples/training/ads-and-ux/ReadMe.txt
new file mode 100644
index 000000000..137397c0d
--- /dev/null
+++ b/samples/training/ads-and-ux/ReadMe.txt
@@ -0,0 +1,9 @@
+This sample demonstrates the integration of an mobile ad SDK with your application. In this case,
+AdMob is used.
+
+The application has the following external dependencies. In order to build, be sure to obtain these
+JAR files and put them under the libs directory.
+1. AdMob SDK
+ http://code.google.com/mobile/ads/download.html
+2. ViewPager depends on the Android Support Package v4 or above.
+ http://developer.android.com/sdk/compatibility-library.html
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/_index.html b/samples/training/ads-and-ux/_index.html
new file mode 100644
index 000000000..a4eeb315b
--- /dev/null
+++ b/samples/training/ads-and-ux/_index.html
@@ -0,0 +1,14 @@
+
This sample demonstrates the integration of a mobile ad SDK with your application. In this case, AdMob is used to illustrate key integration concepts.
+
+The application has the following external dependencies. In order to build, be sure to obtain these JAR files and put them under the libs/ directory.
+
+
+ AdMob SDK - http://code.google.com/mobile/ads/download.html
+
+
+ Android Support Package v4 or above - http://developer.android.com/sdk/compatibility-library.html
+
+
+
+
+Refer to the Advertising without Compromising User Experience class for detail.
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/drawable-hdpi/ic_home.png b/samples/training/ads-and-ux/res/drawable-hdpi/ic_home.png
new file mode 100644
index 000000000..7e52ff595
Binary files /dev/null and b/samples/training/ads-and-ux/res/drawable-hdpi/ic_home.png differ
diff --git a/samples/training/ads-and-ux/res/drawable-mdpi/android_logo.png b/samples/training/ads-and-ux/res/drawable-mdpi/android_logo.png
new file mode 100644
index 000000000..15f1545f0
Binary files /dev/null and b/samples/training/ads-and-ux/res/drawable-mdpi/android_logo.png differ
diff --git a/samples/training/ads-and-ux/res/layout-land/ad_bottom.xml b/samples/training/ads-and-ux/res/layout-land/ad_bottom.xml
new file mode 100644
index 000000000..0b3ac14b5
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout-land/ad_bottom.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/layout-large/ad_bottom.xml b/samples/training/ads-and-ux/res/layout-large/ad_bottom.xml
new file mode 100644
index 000000000..54de75044
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout-large/ad_bottom.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/layout-large/ad_covers_content.xml b/samples/training/ads-and-ux/res/layout-large/ad_covers_content.xml
new file mode 100644
index 000000000..b3359c2a2
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout-large/ad_covers_content.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/layout-large/ad_next_to_button.xml b/samples/training/ads-and-ux/res/layout-large/ad_next_to_button.xml
new file mode 100644
index 000000000..a83f4f237
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout-large/ad_next_to_button.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/layout-large/ad_top.xml b/samples/training/ads-and-ux/res/layout-large/ad_top.xml
new file mode 100644
index 000000000..ea36ee737
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout-large/ad_top.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/layout/ad_bottom.xml b/samples/training/ads-and-ux/res/layout/ad_bottom.xml
new file mode 100644
index 000000000..677f5fd4e
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout/ad_bottom.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/layout/ad_covers_content.xml b/samples/training/ads-and-ux/res/layout/ad_covers_content.xml
new file mode 100644
index 000000000..71764c378
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout/ad_covers_content.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/layout/ad_next_to_button.xml b/samples/training/ads-and-ux/res/layout/ad_next_to_button.xml
new file mode 100644
index 000000000..1284884f1
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout/ad_next_to_button.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/layout/ad_top.xml b/samples/training/ads-and-ux/res/layout/ad_top.xml
new file mode 100644
index 000000000..9d92c457a
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout/ad_top.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/layout/fragment_pager.xml b/samples/training/ads-and-ux/res/layout/fragment_pager.xml
new file mode 100644
index 000000000..89b2d4495
--- /dev/null
+++ b/samples/training/ads-and-ux/res/layout/fragment_pager.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/training/ads-and-ux/res/values/attrs.xml b/samples/training/ads-and-ux/res/values/attrs.xml
new file mode 100644
index 000000000..fa2386626
--- /dev/null
+++ b/samples/training/ads-and-ux/res/values/attrs.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/training/ads-and-ux/res/values/colors.xml b/samples/training/ads-and-ux/res/values/colors.xml
new file mode 100644
index 000000000..531c8c16a
--- /dev/null
+++ b/samples/training/ads-and-ux/res/values/colors.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ #224894
+
diff --git a/samples/training/ads-and-ux/res/values/dimens.xml b/samples/training/ads-and-ux/res/values/dimens.xml
new file mode 100644
index 000000000..46bf31d92
--- /dev/null
+++ b/samples/training/ads-and-ux/res/values/dimens.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ 10dp
+ 5dp
+
+
+ 14sp
+ 18sp
+ 20sp
+
diff --git a/samples/training/ads-and-ux/res/values/strings.xml b/samples/training/ads-and-ux/res/values/strings.xml
new file mode 100644
index 000000000..f143f460a
--- /dev/null
+++ b/samples/training/ads-and-ux/res/values/strings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ Ad shouldn\'t cover content!
+ Ads sample
+ Top Banner Ad
+ Bottom Banner Ad
+ Button that\'s too close
+ Unable to fetch Ad. Waiting for the next refresh.
+ a14b5f8130c17ef
+
diff --git a/samples/training/ads-and-ux/src/com/example/training/ads/AdsCatalogActivity.java b/samples/training/ads-and-ux/src/com/example/training/ads/AdsCatalogActivity.java
new file mode 100644
index 000000000..4050981f0
--- /dev/null
+++ b/samples/training/ads-and-ux/src/com/example/training/ads/AdsCatalogActivity.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.training.ads;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+// Ad network-specific imports (AdMob).
+import com.google.ads.Ad;
+import com.google.ads.AdListener;
+import com.google.ads.AdRequest;
+import com.google.ads.AdView;
+import com.google.ads.AdRequest.ErrorCode;
+
+public class AdsCatalogActivity extends FragmentActivity {
+ private static final int NUM_ITEMS = 4;
+
+ // Ad network-specific mechanism to enable test mode.
+ private static final String TEST_DEVICE_ID = "...";
+
+ PagerAdapter mAdapter;
+ ViewPager mPager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.fragment_pager);
+
+ mAdapter = new PagerAdapter(getSupportFragmentManager());
+
+ mPager = (ViewPager) findViewById(R.id.pager);
+ mPager.setAdapter(mAdapter);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ mPager.setCurrentItem(0);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ public static class PagerAdapter extends FragmentStatePagerAdapter {
+ public PagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return AdFragment.newInstance(position);
+ }
+
+ @Override
+ public int getCount() {
+ return NUM_ITEMS;
+ }
+ }
+
+ public static class AdFragment extends Fragment {
+ private int mNum;
+ private AdView mAdView;
+ private TextView mAdStatus;
+
+ static AdFragment newInstance(int num) {
+ AdFragment af = new AdFragment();
+
+ // Supply num input as an argument.
+ Bundle args = new Bundle();
+ args.putInt("num", num);
+ af.setArguments(args);
+
+ return af;
+ }
+
+ /**
+ * When creating, retrieve this instance's number from its arguments.
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle args = getArguments();
+ mNum = args != null ? args.getInt("num") : 1;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Set up the various ad layouts on different flip pages.
+ final int[] layouts = {
+ R.layout.ad_top,
+ R.layout.ad_bottom,
+ R.layout.ad_next_to_button,
+ R.layout.ad_covers_content };
+ int layoutId = layouts[mNum];
+ View v = inflater.inflate(layoutId, container, false);
+ mAdStatus = (TextView) v.findViewById(R.id.status);
+ mAdView = (AdView) v.findViewById(R.id.ad);
+ mAdView.setAdListener(new MyAdListener());
+
+ AdRequest adRequest = new AdRequest();
+ // adRequest.addKeyword("ad keywords");
+
+ // Ad network-specific mechanism to enable test mode. Be sure to disable before
+ // publishing your application.
+ adRequest.addTestDevice(TEST_DEVICE_ID);
+ mAdView.loadAd(adRequest);
+ return v;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ mAdView.destroy();
+ }
+
+ // Receives callbacks on various events related to fetching ads. In this sample,
+ // the application displays a message on the screen. A real application may,
+ // for example, fill the ad with a banner promoting a feature.
+ private class MyAdListener implements AdListener {
+
+ @Override
+ public void onDismissScreen(Ad ad) {}
+
+ @Override
+ public void onFailedToReceiveAd(Ad ad, ErrorCode errorCode) {
+ mAdStatus.setText(R.string.error_receive_ad);
+ }
+
+ @Override
+ public void onLeaveApplication(Ad ad) {}
+
+ @Override
+ public void onPresentScreen(Ad ad) {}
+
+ @Override
+ public void onReceiveAd(Ad ad) { mAdStatus.setText(""); }
+ }
+ }
+}