- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不是程序员,需要你的帮助。我在我的应用程序中使用 Admob (InterstitialAd)。 SDK 8 不支持我的 GMS 库。如何使用 sdk 8 阻止应用程序中的广告。我找到了代码,但不知道如何正确使用它。if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.FROYO)
package com.training;
public class NoAuthorisationMainActivity extends Activity {
......................
private InterstitialAd interstitial;
...............
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Resources resource = getResources();
Configuration config = resource.getConfiguration();
sharedPreference = PreferenceManager.getDefaultSharedPreferences(this);
if ("ru".equalsIgnoreCase(sharedPreference.getString("language", null))) {
config.locale = RUSSIAN;
} else if ("en".equalsIgnoreCase(sharedPreference.getString("language", null))) {
config.locale = Locale.ENGLISH;
} else if ("es".equalsIgnoreCase(sharedPreference.getString("language", null))) {
config.locale = SPANISH;
}
else {
config.locale = Locale.getDefault();
}
getBaseContext().getResources().updateConfiguration(config, null);
Log.v( "DEBUG", "Main activity starting" );
setContentView(R.layout.main_activity); // ID Activity
Button languageButton = (Button) findViewById(R.id.GoLanguageButton);
languageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Intent LanguageButton = new Intent(MainActivity.this, LanguageLocale.class);
// MainActivity.this.startActivity(LanguageButton);
langDialog().show();
}
});
new DBData(this);
// Prepare the Interstitial Ad
interstitial = new InterstitialAd(NoAuthorisationMainActivity.this);
// Insert the Ad Unit ID
interstitial.setAdUnitId(MY_AD_UNIT_ID);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("6c248b7677c6609d")
.build();
interstitial.loadAd(adRequest);
// Prepare an Interstitial Ad Listener
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
// Call displayInterstitial() function
displayInterstitial();
}
});
findViewById(R.id.noAuthInfo).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent BookButton = new Intent(NoAuthorisationMainActivity.this, WebViewActivity.class);
NoAuthorisationMainActivity.this.startActivity(BookButton);
}
});
findViewById(R.id.noAuthTreker).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent TrackerButton = new Intent(NoAuthorisationMainActivity.this, ShowExercisesListActivity.class);
NoAuthorisationMainActivity.this.startActivity(TrackerButton);
}
});
findViewById(R.id.noAuthInfo2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(NoAuthorisationMainActivity.this, DnevnikTrenirovokActivity.class);
NoAuthorisationMainActivity.this.startActivity(i);
}
});
findViewById(R.id.noAuthTimer).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent TimerButton = new Intent(NoAuthorisationMainActivity.this, TimerMain.class);
NoAuthorisationMainActivity.this.startActivity(TimerButton);
}
});
findViewById(R.id.noAuthBtnAuth).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(NoAuthorisationMainActivity.this, LoginActivity.class));
}
});
findViewById(R.id.noAuthBtnRegistration).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(NoAuthorisationMainActivity.this, RegisterActivity.class));
}
});
}
private void showMessage(String message)
{
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
@Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
setIntent(intent);
// checkMessage(intent);
setIntent(new Intent());
}
// Create Menu
public boolean onCreateOptionsMenu(Menu menu) // Build menu
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_menu, menu); // ID mainmenu for the menu
return true;
}
// The menus with icons
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) // Set cases if you click on the menu button
{
case R.id.close: // Close WebView
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return true;
case R.id.google: // Open new WebView with the e.g. Google Url
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://gym-training.com/")));
return true;
default:
return super.onOptionsItemSelected(item);
// You can build more menus and more cases if you like.
}
}
private Dialog langDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.personal_setting);
String[] mas = getResources().getStringArray(R.array.language_sort_options);
final Configuration config = getResources().getConfiguration();
builder.setItems(mas, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
sharedPreference.edit().putString("language", "auto").commit();
config.locale = Locale.getDefault();
break;
case 1:
sharedPreference.edit().putString("language", "en").commit();
config.locale = Locale.ENGLISH;
break;
case 2:
sharedPreference.edit().putString("language", "ru").commit();
config.locale = RUSSIAN;
break;
case 3:
sharedPreference.edit().putString("language", "es").commit();
config.locale = SPANISH;
break;
}
getResources().updateConfiguration(config, null);
Intent intent = new Intent(NoAuthorisationMainActivity.this, NoAuthorisationMainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
return builder.create();
}
@Override
protected void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
protected void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
public void displayInterstitial() {
// If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
最佳答案
由于很难预测每台设备的状态,因此在访问 Google Play 服务功能而不是 SDK 版本之前,您必须始终检查兼容的 Google Play 服务 APK
要验证 Google Play 服务版本,请调用“isGooglePlayServicesAvailable()”。如果结果代码为 SUCCESS,则 Google Play 服务 APK 是最新的,您可以继续建立连接。但是,如果结果代码为 SERVICE_MISSING、SERVICE_VERSION_UPDATE_REQUIRED 或 SERVICE_DISABLED,则用户需要安装更新。因此,调用 GooglePlayServicesUtil.getErrorDialog() 并向其传递结果错误代码。这会返回一个您应该显示的对话框,其中提供有关错误的适当消息,并提供将用户带到 Google Play 商店安装更新的操作。
关于java - 如何在 Android 应用程序 (sdk 8) 中阻止 InterstitialAd (GMS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24998924/
我正在使用 react-native-firebase/admob 在 react native 中使用 Adbmod,当我尝试在第一次点击时使用插页式广告时,它会打开广告,但从那时起它返回此错误:
我的应用使用了下面的InterstitialAd,下面是从google例子中得到的标准编码。但是,请问为什么没有广告显示? (应用程序正确显示 toast :在 ReceiveAd 上) 我的 mai
我注意到我的应用在 InterstitialAd 上收到的点击次数很少,而且我发现可以通过按“后退”按钮立即关闭广告。通常广告需要几秒钟的时间才会出现,因此用户甚至可以在看到它之前将其关闭(当只出现黑
我正在我的应用程序中实现 InterstitialAd,并按照 Google 代码示例来实现广告。 问题: 大部分时间广告无法正常显示。我已经设置了所有 Activity 以及 list 中的 AdA
更新后com.google.android.gms:play-services-ads至19.7.0它说InterstitialAd & RewardedVideoAd & UnifiedNative
我正在使用 appfeel cordova admob 插件。 https://github.com/appfeel/admob-google-cordova 我想在我的 cordova 应用程序中显
我的横幅广告 View 在真实设备和模拟器上正确显示。但是 interstilialad 现在显示真实设备,尽管它在模拟器上正确显示。对我来说一切都很好。但我不明白为什么不显示。 EzFullScre
自 v5.6.1 起,interstitialAd.setAdListener 已弃用。我现在应该用什么替换已弃用的 Facebook InterstitialAd setAdListener? 最佳
我在我的应用程序中使用 google admob InterstitialAd,但我遇到了问题。当我将我的应用程序安装到手机上时,它运行成功。但是当我将它安装到平板设备时,InterstitialAd
我正在使用 AdMob plugin适用于 Unity3d 上的 Android 游戏。虽然我可以在游戏 session 期间保持屏幕明亮,但在 InterstitialAd 显示期间我无法控制手机行
All other listeners of InterstitialAd are working but only onAdLoaded not working. i have set toast
我正在使用 Admob 的 InterstitialAd。我的应用程序仅在第一次被调用时在“loadAd”处崩溃,并且不可重现(它在 100-200 次或多或少的运行中发生一次)。广告单元 ID 肯定
我正在尝试将 InterstitialAd 添加到我的项目中。我已经添加了必要的库 从sdk管理器下载google服务 将项目导入为android代码 将其添加到属性>库中 这是我的代码: impo
如果发现使用旧设备(2.3.6)的用户向我发送此未捕获的异常: java.lang.NoClassDefFoundError: ayc at ajb.a(:com.google.android.gms
我在使用 InterstitialAdListener 时收到此错误 Anonymous class derived from InterstitialAdListener' must either
更新后 Google Ads SDK to 19.7.0 为 提供已弃用的警告消息InterstitialAd , 而我搜索 this link解决问题但没有成功。 我该如何解决? 这是我的代码 pu
我想在我的应用程序中添加插页式广告,我已完成以下操作: 1。 文件 -> 项目结构 -> 广告:我有标志 adMob 2。我的 gradle.build: project(":android") {
首先,抱歉我的英语不好。 当我构建 apk 并尝试在手机中打开 apk 时,它给出 apk 已停止工作。调用 loadAd 之前必须在 InterstitialAd 上设置广告单元 ID 错误。 我做
我不是程序员,需要你的帮助。我在我的应用程序中使用 Admob (InterstitialAd)。 SDK 8 不支持我的 GMS 库。如何使用 sdk 8 阻止应用程序中的广告。我找到了代码,但不知
我对 Apple 的插页式广告有疑问。我正在 swift 开发我的第一个应用程序,我想尽快把它放到 App store 上。但是当我将插页式广告的代码从 obejctive-c 重写为 swift 时
我是一名优秀的程序员,十分优秀!