Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are simple steps to add an ad banner in your android app. Firstly add this method in your Main activity</p> <pre><code>private void displayAd() { try { AdView adView = new AdView(LettersType.this, AdSize.BANNER, HERE-YOUR-ADMOB-ID); // Lookup your LinearLayout assuming it’s been given // the attribute android:id="@+id/mainLayout" FrameLayout adMobLayout = (FrameLayout)findViewById(R.id.banner); // Add the adView to it adMobLayout.addView(adView); // AdRequest adRequest = new AdRequest(); // adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Initiate a generic request to load it with an ad adView.loadAd(new AdRequest()); adView.setAdListener(new AdListener() { public void onDismissScreen(Ad arg0) { } public void onLeaveApplication(Ad arg0) { } public void onPresentScreen(Ad arg0) { } public void onReceiveAd(Ad arg0) { } public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) { } }); }catch(Exception e) { } } </code></pre> <p>Add this permissions in android manifest</p> <pre><code> &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/&gt; </code></pre> <p>And finally add this in your mainactivity layout XML file</p> <pre><code>&lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/banner" android:layout_centerHorizontal="true" /&gt; </code></pre> <p>This framelayout is the adbanner .</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload