- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Google Play 服务实现 AdMob。到目前为止,我已经显示了默认的测试横幅,但我想尝试一些测试广告。
我读到模拟器 (AVD) 必须将 Google API 16 或 17 作为目标才能测试 AdMob,但是当我创建一个以此为目标的设备时,模拟器无法加载(我把它留了好久20 分钟还没有加载 :( 我只看到闪烁的 android 标志
这是我的 AVD 设备
这是我的 AdFragment 类,其中包含与广告相关的所有代码
public class AdFragment extends Fragment
{
private AdView mAdView;
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.fragment_ad, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
mAdView = (AdView)getView().findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
// Start loading the ad in the background.
mAdView.loadAd(adRequest);
}
/** Called when leaving the activity */
@Override
public void onPause()
{
if (mAdView != null)
{
mAdView.pause();
}
super.onPause();
}
/** Called when returning to the activity */
@Override
public void onResume()
{
super.onResume();
if (mAdView != null)
{
mAdView.resume();
}
}
/** Called before the activity is destroyed */
@Override
public void onDestroy() {
if (mAdView != null)
{
mAdView.destroy();
}
super.onDestroy();
}
}
现在我不确定是我的代码没有生成设备 ID 还是我创建的 AVD 设备有问题。我看的教程都是这样的
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC")
现在我不知道最后一行是 LogCat 给出的代码还是我必须输入的代码。我注意到 developer.google 网站有不同的代码所以我想我不需要包含在我的代码中,因为我还没有得到它。
请帮忙。谢谢。
更新 1我在我的主要 Activity 中的 On Resume 中添加了这段代码
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
int isAvaiable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(isAvaiable == ConnectionResult.SUCCESS)
{
Log.d("TEST", "GPS IS OK");
}
else if(isAvaiable == ConnectionResult.SERVICE_MISSING || isAvaiable == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED || isAvaiable == ConnectionResult.SERVICE_DISABLED)
{
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvaiable, this, 1);
dialog.show();
}
}
最佳答案
用于测试横幅的 API 应为 17 或更高版本。你在这里有一个很好的答案来解释它。 GPS in emulator .
对于与启动模拟器相关的问题,我唯一能给你的建议是尝试VM Acceleration并使用较小的屏幕。您可以尝试其他模拟器,例如 x86Emulator并下载最后一个ISO versions 4.4 .在我的例子中,默认的 android 模拟器需要 10-12 分钟才能在 ldpi 中响应,而另一个在 hdpi 中只有 2 分钟。
关于 addTestDevice,我认为 AdRequest.DEVICE_ID_EMULATOR 就足够了,但如果您在 logcat 中看到设备 ID 的 MD5,则添加此哈希值。
最后但同样重要的是,记得在开始时检查是否安装了 GPS,DOCS 上有说明。
To verify the Google Play services version, call isGooglePlayServicesAvailable(). If the result code is SUCCESS, then the Google Play services APK is up-to-date and you can continue to make a connection. If, however, the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then the user needs to install an update.
这样你就可以避免错误。
关于Android AdMob addTestDevice 没有在 logcat 中获取 deviceID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26170462/
我想从两个表中获取数据。 表一 deviceadd 具有以下列 DeviceID (primary key), DeviceName, SerialNumber, ModelNumber, Make
我的应用程序 (S Educate) 要求我获取 DeviceId(用于分析/推荐),因此我添加了权限 READ_PHONE_STATE,尽管 documentation是无害的,当用户安装时,应用程
我对 TelephonyManager 有疑问。 DeviceId 为空/空白。这是我的代码。我哪里错了? 这是我的java代码 RegistryActivity.java package andro
我的数据库表logs如下: alt text http://www.freeimagehosting.net/uploads/16e974703a.jpg 我想提取设备、pollDate、status
我没有找到一种方法可以使用 azure 流分析查询语言来分析缺少特定事件的流。该流可能包含 DeviceAlive 和 BeaconDetected 事件,其中包含 DeviceId,并且在 Beac
按照本指南操作:https://learn.microsoft.com/nl-nl/azure/azure-functions/functions-bindings-event-hubs#trigge
我没有找到一种方法可以使用 azure 流分析查询语言来分析缺少特定事件的流。该流可能包含 DeviceAlive 和 BeaconDetected 事件,其中包含 DeviceId,并且在 Beac
我正在尝试获取设备ID,以便在我的设备上使用AdMob(是的,我知道我可以在LogCat中显示它,但这只是一个基本程序,我认为我可以毫无问题地编写),但是由于某种原因我得到 NullPointerEx
我有以下代码,它循环遍历机器上的所有视频输入设备,并应显示该输入设备的流。 $.each(devices, function( index, value ) { if(value.kind =
我正在开发一个能够接收推送通知的安卓应用。但我需要有一个 deviceId 才能成功,因为我没有任何 android 手机,所以我曾经在模拟器中测试该应用程序。所以我的问题是,我能否为我的模拟器获取一
在我以前的应用程序中,我使用下面提到的代码为 iOS 设备生成唯一的 deviceId。但问题是每次重新安装应用程序时它都会生成一个新代码。我该如何正确执行此操作? -(NSString*)uniqu
我使用此行将 bin 从成员转换为数字和字符 String bin=Integer.toString(Integer.parseInt(DeviceInfo.getDeviceId(),16)) 现在
我需要帮助的关联PHYSICAL_MONITOR这是我从GetPhysicalMonitorsFromHMONITOR获得与显示器DISPLAY_DEVICE.DeviceID(如 “\?\DISPL
如何在不需要额外权限的情况下正确构 build 备 ID?你应该遵守什么规则? 这个问题是引用这个example code: // Construct the LicenseChecker with
我有一个要求,其中我不应允许用户在超过 1 台设备上安装我的应用。这是一个企业应用程序,我使用企业开发者帐户分发了它。根据Google搜索,我使用IdentifierForVendor来获取唯一的设备
我正在尝试从事件中心(位于 IoTHub 背面)读取设备 ID,但我的 JS 语法似乎错误。 module.exports = function (context, IoTHubMessages) {
我正在尝试使用 Google Play 服务实现 AdMob。到目前为止,我已经显示了默认的测试横幅,但我想尝试一些测试广告。 我读到模拟器 (AVD) 必须将 Google API 16 或 17
Appcelerator Studio 中的新项目可以毫无问题地构建并编译到模拟器。在调用 xcodebuild 后,选择一个 iOS 设备来构建它确实会出现错误。 我已经从 Appcelerator
我们使用 Azure SDK 创建资源组、物联网中心和设备。 例如: iotHubDescription = await iotHubClient.IotHubResource.CreateOrUpd
我将数据从不同的设备传入 IoT 中心,并使用流分析对其进行处理并将其存储在 Blob 存储中。我知道我们可以根据需要的格式在路径中添加我们添加的{date}{time},在该路径中我们也可以添加de
我是一名优秀的程序员,十分优秀!