ANDROID STUDIO : Create an ad or banner that will allow the application\'s user
ID: 3850483 • Letter: A
Question
ANDROID STUDIO : Create an ad or banner that will allow the application's user to learn more about my work as a realtor.
There can be several approaches to this, for example:
1. Once the game closes, an image or layout appears giving information about the realtor business. This image/layout might be a link itself or contain a link to http:// webpage.
2. A click-able footer that pops up, scrolls, fades in/out, all of the aforementioned or just stays static acting similar to #1.
Separate the solution from the application itself so that it can be reused in other applications.
Do NOT use a "ready made" solution such at AdMob or AdSense
Explanation / Answer
MainActivity.java
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
private InterstitialAd interstitial;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from activity_main.xml
setContentView(R.layout.activity_main);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(MainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId("ca-app-pub-123456789/123456789");
//Locate the Banner Ad in activity_main.xml
AdView adView = (AdView) this.findViewById(R.id.adView);
// Request for Ads
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("CC5F2C72DF2B356BBF0DA198")
.build();
// Load ads into Banner Ads
adView.loadAd(adRequest);
// Load ads into Interstitial Ads
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
th code is very large so i am giving you the link of the code :
http://www.androidbegin.com/integrating-new-google-admob-banner-interstitial-ads/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.