android webview admob不显示

android webview admob not displaying(android webview admob不显示)

本文介绍了android webview admob不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i want to use google adds at bottom of my page.. into the emulator it properly displays the add but in device it doesn't
it gives me..

07-20 06:16:24.931: WARN/webcore(4289): Can't get the viewWidth after the first layout
07-20 06:16:25.101: WARN/Ads(4289): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
07-20 06:16:25.111: INFO/Ads(4289): onFailedToReceiveAd(Invalid Google Ad request.)
07-20 06:16:28.957: WARN/PowerManagerService(175): Timer 0x7->0x3|0x0
07-20 06:16:28.957: INFO/PowerManagerService(175): Ulight 7->3|0
07-20 06:16:30.351: WARN/InputManagerService(175): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4a43b8f8
07-20 06:16:45.961: WARN/PowerManagerService(175): Timer 0x3->0x1|0x0
07-20 06:16:45.961: INFO/PowerManagerService(175): Ulight 3->1|0

i cant understand what is the problem? the same code is properly running on the emulator but not in device my XML file is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:id="@+id/rltvLayout"
    android:layout_height="fill_parent">

    <LinearLayout android:id="@+id/linearLayout1"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:orientation="vertical">
        <WebView android:id="@+id/webView" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:fitsSystemWindows="true"/>

        </LinearLayout>
        <LinearLayout android:layout_width="fill_parent"
 android:id="@+id/ad_layout"
 android:layout_height="wrap_content"
 android:gravity="bottom"
 android:layout_alignParentBottom="true"
 android:layout_alignBottom="@+id/home_layout">
 </LinearLayout>
            </RelativeLayout>

解决方案

i've use this in xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent" android:id="@+id/rltvLayout1"
    android:layout_height="fill_parent">
    <LinearLayout android:id="@+id/linearLayoutwebview"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:orientation="vertical">
        <WebView android:id="@+id/webView1"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:fitsSystemWindows="true" />
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/ad_layout" android:layout_height="wrap_content"
        android:gravity="bottom" android:layout_alignParentBottom="true"
        android:layout_alignBottom="@+id/home_layout">
        <com.google.ads.AdView android:layout_width="wrap_content"
            android:layout_height="wrap_content" ads:adUnitId="here put ID"
            ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" />

    </LinearLayout>
</RelativeLayout>

one more point i found is that
There are some changes to the way Admob works in version 4.1.0
1) Remove attrs.xml (or if you need it for your own custom attributes, remove the parts related to AdViews).

2) Change the namespace in your layout from xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename" to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" see more...

这篇关于android webview admob不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:android webview admob不显示

基础教程推荐