我试图在我的应用程序上设置admob并且它没有工作它出现错误就行了,你必须将你的用户ID放入admob服务工作:(
package com.google.example.ads.fundamentals;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
/**
* A simple {@link Activity} that embeds an AdView.
*/
public class BannerSample extends Activity {
/** The view to show the ad. */
private AdView adView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
这里的错误
//制作广告
adView =新AdView(此广告,AdSize.BANNER,a1515 * * **** );
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
/** Called before the activity is destroyed. */
@Override
public void onDestroy() {
// Destroy the AdView.
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
答案 0 :(得分:0)
我认为问题是AdView类中的第三个参数必须是字符串
尝试将其更改为:
adView = new AdView(this, AdSize.BANNER, "a1515******");
我希望这有助于你
欢呼声,