1. Right click on your app project in Eclipse and choose Properties
2. Select Java Build Path and the Libraries tab. Then click Add External JARs... to add the Google AdMob Ads JAR.
3.instantiate a com.google.ads.AdActivity in its AndroidManifest.xml and make ad requests requires the networking permissions INTERNET and ACCESS_NETWORK_STATE
Xml代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hsj.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
方式一 在你的Activity里面写入下面的代码
Java代码:
public class UnityAdActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, "你的发布者ID");
LinearLayout layout = (LinearLayout) findViewById(R.id.adView);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
}
这样就ok了,可以编译程序运行试一下。