我在Revmob上有问题。我想在我的项目中添加revmob横幅广告,但它没有显示任何内容。请帮我找出我的错误。
我的MainActivity.java
package com.test.project;
import android.util.Log;
import rm.com.android.sdk.Rm;
import rm.com.android.sdk.RmListener;
import rm.com.android.sdk.ads.banner.RMBannerView;
public class MainActivity extends BaseActivity {
String YOUR_REVMOB_APP_ID = "59d8ea0d23a7ae2ea50a0688";
String YOUR_REVMOB_PLACEMENT_ID = "59d8ea0d23a7ae2ea50a0688";
RMBannerView banner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
Rm.init(this, YOUR_REVMOB_APP_ID);
/** Cache Banner **/
Rm.cacheBanner(YOUR_REVMOB_PLACEMENT_ID, new RmListener.Cache() {
@Override
public void onRmAdReceived() {
Log.i("RevMob","Banner Ready to be Displayed");
//At this point, the banner is ready to be displayed.
showBanner();
}
@Override
public void onRmAdNotReceived(String message) {
Log.i("RevMob","Banner Not Failed to Load");
}
});
}
public void showBanner() {
if (Rm.isBannerLoaded(YOUR_REVMOB_PLACEMENT_ID)) {
banner = Rm.getBanner(this, YOUR_REVMOB_PLACEMENT_ID, new RmListener.Get() {
@Override
public void onRmAdDisplayed() {
Log.i("RevMob","Banner Displayed");
}
@Override
public void onRmAdFailed(String message) {
Log.i("RevMob","Banner Not Failed to Load");
}
@Override
public void onRmAdDismissed() {
Log.i("RevMob","Banner Dismissed");
}
@Override
public void onRmAdClicked() {
Log.i("RevMob","Banner Clicked");
}
});
/** Show Banner **/
ViewGroup view = (ViewGroup) findViewById(R.id.layout_banner);
view.removeAllViews();
view.addView(banner);
}
}
}
我的activitymain.xml
<linearlayout android:id="@+id/layout_banner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal">
</linearlayout>
我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.test.project">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
tools:replace="android:icon"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
android:theme="@style/AppLTheme"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="rm.com.android.sdk.RmInterstitial"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
</application>
</manifest>
我的gradle
依赖{ 编译fileTree(包括:['* .jar'],dir:'libs') androidTestCompile( 'com.android.support.test.espresso:咖啡核:2,2,2', { 排除组:'com.android.support',模块:'support-annotations' }) 编译'com.android.support:appcompat-v7:25.2.0' testCompile'junit:junit:4.12' 编译文件('libs / rm.jar') }
帮我解决这个问题!