Tag Archives: Java

Ad Mixer (II) – How to mix Quattro Wireless Ads, AdMob Ads, and your own clickable Ads

What an impressive long blog title!
Quattro Wireless Ads has slightly better eCPM than AdMob, and it allows your to put a default image Ads (not clickable). However, its fillrate is unbearably low (50% ~ 90%, typically around 75%, according to my 2 week test). Here, I’m showing you a way to mix Ads from Quattro Wireless, AdMob, and your own Ads.
For information about how to setup Ads on android apps using Quattro Wirelss, click here.
Step 1: Prepare your own banner ads.
Setp 2: Add the following Ads banner in your layout xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

<FrameLayout android:layout_width="fill_parent"
android:layout_height="50dp" android:gravity="top">
 
<ImageView android:id="@+id/ownads" android:src="@drawable/banner_ad"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
 
<com.admob.android.ads.AdView
android:id="@+id/adMob" android:layout_width="fill_parent"
android:layout_alignParentTop="true" android:layout_marginTop="10dp"
android:layout_height="fill_parent" />
 
<com.qwapi.adclient.android.view.QWAdView
android:id="@+id/QWAd" android:layout_width="fill_parent"
android:layout_height="fill_parent" qwad:siteId="xyz"
qwad:publisherId="xyz" qwad:mediaType="banner,text"
qwad:displayMode="autoRotate" qwad:placement="top"
qwad:animation="fade" />
</FrameLayout>

Step 3: Implement Quattro’s AdEventsListener …

Ad Mixer (I) – How to mix AdMob Ads and your own clickable Ads

If you are an AdMob publisher, you will know how fluctuating their fillrates are: mine varies from 40% to 100%. What’s even worse is that they don’t support default Ads. So I decide to mix in mine:
For information about how to setup Ads on android apps using AdMob, click here.
Step 1: Prepare your own banner ads (320×50 or 480×50. Note AdMob’s ads has a fixed height of 50 pixels).
Step 2: Replace your AdView with the following framelayout in your layout xml:

1
2
3
4
5
6
7
8
9
10
11
12

<FrameLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal">
 
<ImageView android:id="@+id/ownads" android:src="@drawable/banner_ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
 
<com.admob.android.ads.AdView android:id="@+id/ad"
android:layout_width="fill_parent" android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:backgroundColor="#000000" app:textColor="#FFFFFF" />
</FrameLayout>

Step 3: Change your activity to include this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

private static final Uri SAME2D_URI =
Uri.parse("market://search?q=pname:com.clingmarks.same2dfree");
 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) …

JVM Wrong Timezone Bug

A few weeks ago we noticed that one of our applications had wrong timestamps in the log files by late for an hour.
At first I thought the timezone setting in the OS could be wrong but our ops people confirmed it is actually correct. Then I thought the JVM settings on that server must have something wrong. But I compared the JVM directories on the problematic server to a good server, they are exactly the same. This puzzles me. Then I wrote a simple Java app to print out all system properties and found that on the “bad” server, the default timezone is “GMT-08:00″ instead of “US/Pacific”.
After searching online, it turned out this is actually a bug in Java.
In short, in some cases JVM can get a wrong timezone from the machine, even if all the settings are right. What happened is when JVM starts, it looks for a matched …