奖励测试广告显示但不是真实的
Posted
技术标签:
【中文标题】奖励测试广告显示但不是真实的【英文标题】:Rewarded Test Ads shows but not the real one 【发布时间】:2020-08-12 19:08:55 【问题描述】:在我在 android Studio 上制作的应用程序中实施激励广告(使用 AdMob)时遇到了一些问题。 当我输入测试 App ID 和测试 Ads UNIT 时,它运行良好并且测试广告出现,但是当我尝试输入我自己的 App ID 和我自己的 Ads UNIT 时,广告不再加载。
我在创建我的 admob 帐户后等待了一个多星期,所以对我来说问题与它无关。
我想知道你是否可以帮助我。
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="(hide)">
<!-- Internet Permission -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1726769558644129~3661017334" />
<activity
android:name=".SpashScreenActivity"
android:theme="@style/SplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
<activity android:name=".DashboardActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".Main" />
</application>
</manifest>
HomeFragment.java:
/**
* A simple @link Fragment subclass.
*/
public class HomeFragment extends Fragment implements RewardedVideoAdListener
public HomeFragment()
// Required empty public constructor
//init view
ImageButton addCoinsBtn;
//AdRewarded
private RewardedVideoAd mAd;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
// Inflate the layout for this fragment
View view =inflater.inflate(R.layout.fragment_home, container, false);
MobileAds.initialize(getActivity(), "ca-app-pub-1726769558644129~3661017334");
// Use an activity context to get the rewarded video instance
mAd = MobileAds.getRewardedVideoAdInstance(getActivity());
mAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
addCoinsBtn.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
if(mAd.isLoaded())
mAd.show();
addCoinsBtn.setVisibility(View.INVISIBLE);
waitAdLL.setVisibility(View.VISIBLE);
);
return view;
private void loadRewardedVideoAd()
mAd.loadAd("ca-app-pub-1726769558644129/3118091850", new AdRequest.Builder().build());
// Required to reward the user.
@Override
public void onRewarded(RewardItem reward)
// Reward the user.
// The following listener methods are optional.
@Override
public void onRewardedVideoAdLeftApplication()
Toast.makeText(getActivity(), "onRewardedVideoAdLeftApplication",Toast.LENGTH_SHORT).show();
@Override
public void onRewardedVideoAdClosed()
//Toast.makeText(getActivity(), "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
loadRewardedVideoAd();
@Override
public void onRewardedVideoAdOpened()
//Toast.makeText(getActivity(), "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
@Override
public void onRewardedVideoStarted()
//Toast.makeText(getActivity(), "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode)
Toast.makeText(getActivity(), "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
loadRewardedVideoAd();
@Override
public void onRewardedVideoCompleted()
@Override
public void onResume()
mAd.resume(getActivity());
super.onResume();
@Override
public void onPause()
mAd.pause(getActivity());
super.onPause();
@Override
public void onDestroy()
mAd.destroy(getActivity());
super.onDestroy();
@Override
public void onRewardedVideoAdLoaded()
//Toast.makeText(getActivity(), "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
My Admob information
感谢您的帮助。
Krisix
【问题讨论】:
【参考方案1】:检查您的 Admob 帐户,我遇到了类似的问题,但结果证明我的帐户存在问题。 (如果正在展示测试广告,则可能不是代码问题。)
尝试添加此代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
// Inflate the layout for this fragment
View view =inflater.inflate(R.layout.fragment_home, container, false);
MobileAds.initialize(this, new OnInitializationCompleteListener()
@Override
public void onInitializationComplete(InitializationStatus initializationStatus)
);
// Use an activity context to get the rewarded video instance
mAd = MobileAds.getRewardedVideoAdInstance(getActivity());
mAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
// Your code
...
【讨论】:
感谢您的改进!但是我的 Admob 帐户可能有什么问题?您的帐户有什么问题? 我的账号被重复了,我以前用同一个银行账号使用AdMob,导致广告展示出现问题。以上是关于奖励测试广告显示但不是真实的的主要内容,如果未能解决你的问题,请参考以下文章
Cordova - AdMob 插件可以显示测试广告,但不能显示真实广告
我正在尝试在我的设备上获得真实的广告,但应用在我的 Android 应用上显示测试广告
Admob 测试广告不起作用,只有真实的广告在显示 - Android
Admob 测试广告不起作用,只有真实的广告在显示 - Android