How To Create Facebook Interstitial Ads Android Studio
Hello friends how are you all.... You can easily create a Facebook Interstitial Ads
by watching the video.Build.gradle:
....Copy any code....
implementation 'com.facebook.android:audience-network-sdk:5.4.1'
implementation 'com.facebook.android:audience-network-sdk:5.4.1'
AndroidManifest.xml:
....Copy the code as shown on the video....
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.ads.AudienceNetworkActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
</application>
</manifest>
MainActivity java:
....Copy the code as shown on the video....
public class InterstitialAdActivity extends Activity { private final String TAG = MainActivity.class.getSimpleName(); private InterstitialAd interstitialAd; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Instantiate an InterstitialAd object. // NOTE: the placement ID will eventually identify this as your App, you can ignore it for // now, while you are testing and replace it later when you have signed up. // While you are using this temporary code you will only get test ads and if you release // your code like this to the Google Play your users will not receive ads (you will get a no fill error). interstitialAd = new InterstitialAd(this, "YOUR_PLACEMENT_ID"); // Set listeners for the Interstitial Ad interstitialAd.setAdListener(new InterstitialAdListener() { @Override public void onInterstitialDisplayed(Ad ad) { // Interstitial ad displayed callback Log.e(TAG, "Interstitial ad displayed."); } @Override public void onInterstitialDismissed(Ad ad) { // Interstitial dismissed callback Log.e(TAG, "Interstitial ad dismissed."); } @Override public void onError(Ad ad, AdError adError) { // Ad error callback Log.e(TAG, "Interstitial ad failed to load: " + adError.getErrorMessage()); } @Override public void onAdLoaded(Ad ad) { // Interstitial ad is loaded and ready to be displayed Log.d(TAG, "Interstitial ad is loaded and ready to be displayed!"); // Show the ad interstitialAd.show(); } @Override public void onAdClicked(Ad ad) { // Ad clicked callback Log.d(TAG, "Interstitial ad clicked!"); } @Override public void onLoggingImpression(Ad ad) { // Ad impression logged callback Log.d(TAG, "Interstitial ad impression logged!"); } }); // For auto play video ads, it's recommended to load the ad // at least 30 seconds before it is shown interstitialAd.loadAd(); } }
...Please do not copy the code...
The code is only made for our video, please do not copy it....
InterstitialAd text id 352621488751133_352621998751082
How To Create Facebook Interstitial Ads Android Studio
Reviewed by Code Labe
on
June 12, 2019
Rating: