I've got a problem with Admob not showing up Ads...
Here's the LogCat:
WARN/AdMobSDK(502): Ignoring requestFreshAd() because we are requesting an ad right now already.
INFO/AdMobSDK(502): No fill. Server replied that no ads are available (1164ms)
INFO/AdMobSDK(502): No fill. Server replied that no ads are available (846ms)
I've tried test mode, no test mode, emulator, real phone, etc. It never shows anything up, but I get requests and prints on Admob stats, like if it ever worked...
AFAIK, I did everything in the Admob Android SDK... the only thing that could be the cause of any problems, IMHO, would be the fact that I'm using tabbed layout with scrollview and then a relativelayout where the ad shows...
Here's a sample of the layout for a tab:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.xxx.xxx"
android:id="#+id/tababout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000"
android:padding="10px">
<ImageView
android:id="#+id/label_img"
android:src="#drawable/about_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside" />
<TextView android:id="#+id/label_know_more_desc"
style="#style/Desc"
android:layout_below="#id/label_img"
android:text="#string/tab_about_know_more_desc" />
<Button android:id="#+id/bt_know_more"
style="#style/Button"
android:gravity="center_vertical|center_horizontal"
android:layout_below="#id/label_know_more_desc"
android:text="#string/tab_about_know_more_bt" />
<com.admob.android.ads.AdView android:id="#+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF" myapp:secondaryTextColor="#CCCCCC" />
</RelativeLayout>
</ScrollView>
And here's the main.xml, not that I think you need it:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000"
android:paddingTop="5px">
</FrameLayout>
</LinearLayout>
</TabHost>
I've read in Admob ads will not display when placed inside a tabview that the problem could be the 10px padding I'm throwing in, but even if I disable that, it doesn't work.
I even tried moving the xmlns:myapp to RelativeLayout, but obviously didn't change anything....
Also, I've made my first live ad request over 24 hours ago...
EDIT
Ok, now I'm getting somewhere, I've managed to get test ads showing up (my setTestDevices was too late in the onCreate code, I pushed it up to the first lines), but not real ones... am I missing something? I obviously commented out the setTestDevices line and no ads show up
EDIT 2
Well, I added two internal ads (I already had internal ads enabled, but no internal ads set), and suddenly ads started showing on my app (not only internal ads).
I guess everything altogether made it work?! :)
Thanks everyone!
You aren't positioning the ad's in the RelativeLayout (they need a layout_above or layout_below or whatever to specify where to put them).
Also there is a minimum size for admob that you might want to ensure you match, I think it's like 48dip in height at least, not sure what the horizontal is.
Lastly I don't know where you are trying to place your ad's, but it probably would make more sense in your main frame-layout, I have a padding at the bottom of my app which I use for the ad-view.
Edit: also if your app is public check for ad-revenue. Android pre 2.3 allowed ad's to be hidden behind views and still register clicks. I actually made my initial $1 before my ad's were even visible by anyone.
Another reason that the AdMob Ads won't show up is that you haven't declared the AdActivity which will display the ads when they are clicked on. Without the AdActivity declared in my AndroidManifest.xml, I don't see the ads. With it declared, the Ads show up.
...AndroidManifest.xml...
<!-- AdMob -->
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
Related
I am working on a scrollview that contain a webview, it works perfect on the 2.3, 4.1 , but when I try it on the 4.4 emulator, it show
View too large to fit into drawing cache, needs 5744640 bytes, only 3932160 available
The webview is just blank.
And it is the layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="#+id/newsTitle"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/last_update" />
<WebView
android:id="#+id/newsContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/last_update" />
<TextView
android:id="#+id/newsDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/last_update" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I tried to use mywebView.setDrawingCacheEnabled(false); but it just return the same warning.
Also, I find the problem occur when the webpage is overscreen size , but when I show it , I find the layout of the web is slightly different, on 2.3 , 4.1 , it can simply start the new line if the word is exceed the page, however , in 4.4 it does not , so part of the word is out of the screen .
How to fix it? Thanks
My Suggestion is give layout height to webview so that it wont exceed the your specified height
<LinearLayout
android:id="#+id/webview1"
android:layout_width="fill_parent"
android:layout_height="150dip" >
<WebView
android:id="#+id/sampletxt"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
In your activity just include the below lines
SampleTxt.getSettings().setLoadWithOverviewMode(true);
SampleTxt.getSettings().setJavaScriptEnabled(true);
SampleTxt.loadData("Your Text To show the Webview",
"text/html; charset=UTF-8", null);
It will work fine. any doubts let me know
I suggest you to use your own WebView client. In android we can use WebViewClient or WebChromeClient. Using this you would get better result that you want. Just try it and check.
For WebViews in Android, you should start from the assumption that things are buggy. They shouldn't be, but as you discovered, if you make the background a flat color, it "resolves" the issue.
Having said that, it is still a good idea to keep in mind that you're dealing with a wide range of mobile devices with wildly different processing and memory allocations when you're coding for Android phones, so always be sure to test on a real device.
If you don't have at least 4 or 5 different physical Android devices that you can test on, then look around for services that allow you to use their devices to test remotely. Never believe that because you have tested something in an emulator, it will behave the same on a real device.
i have created a game(surfaceview) and i am trying to implement admob wherein it must be fixed at the bottom.. i have successfully implemented the admob and shows it properly but what i did is i call it in main activity.
AdView adView = (AdView)findViewById(R.id.adView);
adView.loadAd(new AdRequest());
and i have this on all layouts
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/unit_id"
ads:loadAdOnCreate="true"
/>
what i need to do is show the admob but it will not be affected even if the screen switches it is fixed in the bottom part of the screen. i have searched for some thing like this but i have no success. i hope someone can help or even explain on how i can achieve this.
P.S. its like 1 banner for all activities.
I think it will be difficult (or impossible) to have just a single unique banner span multiple Activities. The ActivityGroup group class may have allowed this kind of thing, but it was never popular and anyway has been deprecated for a while.
Meantime there remains plenty of demand for the UX motif of switching between major views within the confines of one screen. But the mechanism has been reworked to use Fragments. If you can make your SurfaceView stuff work within a Fragment, then that might be your best bet. A layout might look something like this:
<LinearLayout>
<Fragment>
<AdView>
<LinearLayout>
When I did this kind of thing recently, I just put the AdMob code at the bottom of every Activity, and let it reload a fresh ad with every push. There has been no scolding from the Google side regarding too-frequent ad requests, and I am getting plenty of clicks.
Good luck!
Use Only Xml Coding without Java Code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="App ID"`enter code here`
ads:testDevices="25"
ads:loadAdOnCreate="true" />
</RelativeLayout>
Can you wrap the whole screen in a relative layout? You can then align the banner to the parent's bottom. You other items should be declared with layout_above to keep them above the banner. The easiest way is to wrap them in another layout.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adView" >
... your other items can go here
</RelativeLayout>
<com.google.ads.AdView
android:id="#id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="App ID"`enter code here`
ads:testDevices="25"
ads:loadAdOnCreate="true" />
</RelativeLayout>
I'm using the latest android admob SDK 6.3.1 and the first ad is downloaded and is shown on the device. Then after the refresh rate time is due, in my case 30 seconds, logcat shows that the ad has been downloaded and the new add is shown correctly. However after a second or less the new ad disappears leaving the space where the add should be blank.
Through trial and error I have found that if I touch the blank space where the ad should be it opens the correct 2nd ad link in the browser. So the add appears to be hidden in some way.
Also if I touch the bottom left hand corner of the blank 2nd ad, then the 2nd ad is shown correctly.
I've tried this with both relative and linear layouts and on different devices but the same thing happens. The first Ad shows correctly, after the refresh interval, the 2nd and all subsequent ads are downloaded and briefly displayed before going blank.
As well as trying different layouts I have also tried setting adview code in XML and programmatically in java source.
That fact that I briefly see the 2nd ad confirms that everything is okay admob server side so that makes me think it's the layout. But I have tried every combination can think of without success.
Ive tried setting: android:layout_width="320dp" android:layout_height="50dp" instead of "wrap_content" or "fill_parent".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxxxxxxxxxxxxxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
This is what I have now which is as per the official admob page.
Manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
This is my third day trying to solve this, has anyone got any clues?
Do you think it could be device specific. Or API specific.
Best Answer for This Question is that :-
You can set up an Animation to slide the banner down, and when it's out of the view (setup a onAnimationComplete listener) call it's method :
Code in Activity:-
For visible:-
setVisibility(View.VISIBLE);
For:not Hide
setVisibility(View.INVISIBLE);
so it will not take up space in layout any more.
I'm pretty sure this can happen if the same adview id name is used in more than one activity xml.
android:id="#+id/adMob1"
I'm trying to implement Millennial media ads on my application. I have set it up via XML, but when I run the app, it only shows a white rectangle that takes up half the screen.
Also in my log I get an
Millennial ad return failed. Zero content lenght returned.
My XML looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://millennialmedia.com/android/schema"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/mainLay">
<com.millennialmedia.android.MMAdView
android:id="#+id/mmadview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:apid="APID"
app:adType="MMBannerAdTop"
app:refreshInterval="30"
app:accelerate="true"
app:ignoreDensityScaling="false"
/>
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
This is Jason from Millennial Media. This should be fixed by correctly sizing your advertisement unit. Take a look at XML Layout.
And you'll see that the XML includes:
app:height="60"
app:width="480"
This will constrain the advertisement so that it does not take over the screen and cause the SDK to ask our servers for the right size advertisement, which could solve your no response issue.
If you're still not seeing us fill your advertisement requests, or if you're having any other issues with the SDK, please do not hesitate to open a ticket at https://support.mmedia.com/.
I am trying to display a text box using textView.I am adding some data in it during runtime. I just want it to display a box of size 23 lines.
Code am using is this.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/twittertext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdge="vertical"
android:maxLines="23"
android:minLines="23"
android:background="#drawable/dropshadow"
android:scrollbars="vertical"
android:text="Getting data on your slow n/w..."
android:textColor="#ffffff"
/>
</ScrollView>
</LinearLayout>
Now when i see this in emulator it's coming perfectly (Android 2.2) but when i test the same code in a real device (Wildfire 2.2.1) the box is not coming for 23 lines. Rather it just show a 5 line box. Am able to scroll but looks like the
:minLine
is not working.
Please help me.
Ok. I dont have a answer for it. But this is how i solved, just in case someone else want it.
I have used the screen pixels and then calculated the pixels i need for the view. Then added the same as
android:layout_height
property and it worked for me.