To integrate Ads in your application
Step-1 you need to create Linear layout of 320x50 size see this code
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="320dp"
android:layout_height="50dp"
android:orientation="vertical" >
</LinearLayout>
Step-2 Integrate GoogleAdMobAdsSdk-6.0.0.jar file which is available on internet.
Now Paste this .Jar file in your Project.
now,
integrate it using (Right click on Android Project --> Properties --> Java Build path --> Libraries --> Add Jars --> select your project and select GoogleAdMobAdsSdk-6.0.0.jar file --> now select Order and Export --> Select All --> Ok)
Step-3 Give Internet and Network Access Permission from Manifest.xml file
Step-4 Put this code in Manifest file under application tag.
<activity
android:name="com.google.ads.AdActivity"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Step-5 Open Project Properties file and change target to 14 or higher.
# Project target.
target=android-14
Step-6 Put this method in your Activity file and call wherever you want to show Ads.
public void DisplayAds() {
// Create the adView
adView = new AdView(this, AdSize.BANNER, "YOUR KEY");
// adView .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
// LayoutParams.WRAP_CONTENT));
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
AdRequest re = new AdRequest();
re.setTesting(false);// this must be false when apps is released in the
// market
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
NJOY--- RoNaK PaNdYa
Step-1 you need to create Linear layout of 320x50 size see this code
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="320dp"
android:layout_height="50dp"
android:orientation="vertical" >
</LinearLayout>
Step-2 Integrate GoogleAdMobAdsSdk-6.0.0.jar file which is available on internet.
Now Paste this .Jar file in your Project.
now,
integrate it using (Right click on Android Project --> Properties --> Java Build path --> Libraries --> Add Jars --> select your project and select GoogleAdMobAdsSdk-6.0.0.jar file --> now select Order and Export --> Select All --> Ok)
Step-3 Give Internet and Network Access Permission from Manifest.xml file
Step-4 Put this code in Manifest file under application tag.
<activity
android:name="com.google.ads.AdActivity"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Step-5 Open Project Properties file and change target to 14 or higher.
# Project target.
target=android-14
Step-6 Put this method in your Activity file and call wherever you want to show Ads.
public void DisplayAds() {
// Create the adView
adView = new AdView(this, AdSize.BANNER, "YOUR KEY");
// adView .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
// LayoutParams.WRAP_CONTENT));
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
AdRequest re = new AdRequest();
re.setTesting(false);// this must be false when apps is released in the
// market
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
NJOY--- RoNaK PaNdYa
No comments:
Post a Comment