[英]Admob does not show ads in android
I don't know why, but Admob does not show my ads, but my application runs perfectly. 我不知道为什么,但是Admob不会显示我的广告,但是我的应用程序可以完美运行。
Here is my activity: 这是我的活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("GameActivity", "started");
context = this.getApplicationContext();
Uri game = this.getIntent().getData();
if (game != null) {
if (game.getScheme().equals ("file")) {
gamePath = game.getPath();
} else {
copyGameToCache (game);
}
Log.d("GameActivity", "Selected the file: " + getGamePath());
}
super.onCreate(savedInstanceState);
getWindowManager().getDefaultDisplay().getMetrics(metrics);
adView = new AdView(mSingleton);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-1209995634500922/8885931497");
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
mLayout.addView(adView, params);
}
And this is my androidManifest.xml: 这是我的androidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.love2d.android"
android:versionCode="14"
android:versionName="0.9.1b"
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Application"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<service android:name=".DownloadService" />
<activity
android:name="GameActivity"
android:configChanges="orientation|screenSize"
android:label="Application"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="tv.ouya.intent.category.GAME"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:scheme="content" />
<data android:mimeType="application/x-love-game" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.love" />
<data android:host="*" />
</intent-filter>
</activity>
<activity
android:name="DownloadActivity"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="*"
android:pathPrefix="*"
android:mimeType="*/*"
android:pathPattern=".*\\.love" />
<data android:scheme="https"
android:host="*"
android:pathPrefix="*"
android:mimeType="*/*"
android:pathPattern=".*\\.love" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
</manifest>
My application starts without any errors, I can use it perfectly but it does not show the ad. 我的应用程序启动时没有任何错误,我可以完美使用它,但是它不会显示广告。 Can someone tell me what I'm doing wrong?
有人可以告诉我我在做什么错吗?
you probably need to put a test device, something like this: 您可能需要放置一个测试设备,如下所示:
String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] digest = md5.digest(android_id.getBytes());
String deviceId = Base64.encodeToString(digest, 0);
AdRequest adRequest = new dRequest.Builder().addTestDevice("17BB429573B0FA8677D27957B98C7005").build();
adView.loadAd(adRequest);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.