Я изо всех сил пытаюсь добавить admob в мое приложение, основанное на AppCompatActivity. Я пробовал несколько способов, как автоматически сгенерированный способ ( admob ), некоторые из которых не удалось. Ниже приведен основной класс деятельности для справки.
public class WorldClockActivity extends AppCompatActivity {
private static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
// Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) {
ClockListFragment list = new ClockListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
}
//try to add any other view
MobileAds.initialize(this,
"ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx");
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
Где в качестве другого фрагмента ClockListFragment Код активности приведен ниже.
public static class ClockListFragment extends ListFragment implements
LoaderManager.LoaderCallbacks<Cursor>, PauseSource {
private CursorAdapter mAdapter;
private ActionMode mMode;
private OnSharedPreferenceChangeListener mSpChange;
private boolean mAutoSortClocks;
private final List<PauseListener> mListeners = new ArrayList<>();
Не уверен, что я делаю глупую ошибку. Любая помощь будет оценена.