<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="xxx" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name="com.google.android.gms.ads.AdActivity" />
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
</manifest>
This is the code in mainactivity.java
import android.os.Bundle;
import org.apache.cordova.*;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
public class MainActivity extends CordovaActivity
{
private AdView mAdView;
private String ad_unit_id = "xxx";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
// Set Ads
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
// Create a banner ad. The ad size and ad unit ID must be set before calling loadAd.
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.setAdUnitId(ad_unit_id);
// Create an ad request.
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
// Add the AdView to the view hierarchy.
layout.addView(mAdView);
// Start loading the ad.
mAdView.loadAd(adRequestBuilder.build());
// Show Ads
addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
@Override
public void onResume() {
super.onResume();
// Resume the AdView.
mAdView.resume();
}
@Override
public void onPause() {
// Pause the AdView.
mAdView.pause();
super.onPause();
}
@Override
public void onDestroy() {
// Destroy the AdView.
mAdView.destroy();
super.onDestroy();
}
}
protected void onCreate(Bundle savedInstanceState) {
....
RelativeLayout parentLayout = new RelativeLayout(this);
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("YOUR AD UNIT ID");
RelativeLayout.LayoutParams adViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT
, RelativeLayout.LayoutParams.WRAP_CONTENT);
adViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
parentLayout.addView(adView, adViewParams);
AdRequest adRequest = new AdRequest.Builder()
.build();
adView.loadAd(adRequest);
addContentView(parentLayout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT
, RelativeLayout.LayoutParams.MATCH_PARENT));
}
--
---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/fe71f89f-c5d6-4fe7-9163-40d62b47eb6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.