Phonegap + Android + Admob SDK

3,410 views
Skip to first unread message

M Sree Abhinav

unread,
Dec 25, 2011, 7:02:23 AM12/25/11
to phonegap
Admob has stopped serving even Smartphone Web Ads. Previously, this
was the perfect solution to serving admob ads on phonegap
applications. I want to ask if anyone has got Admob working on an
Android phonegap application using the Native sdk. The issue i have is
that because of the super.loadUrl("file:///android_asset/www/
index.html") superimposes over the entire LinearLayout which houses
the ad, if done following the example on the admob site. Is there
anyway in which we can reduce the size of droidgap webview so that the
native layout is also displyed. Google wants us to use Adsense. But
since the phonegap android app is not a website, tracking becomes a
major issue. Please help.

Dan Shookowsky

unread,
Dec 27, 2011, 7:54:15 AM12/27/11
to phonegap
I used the admob android sdk in my app, replacing the findViewById
call with a direct reference to super.root

At least in my case everything seems to resize correctly.

Amr Elgretly

unread,
Dec 27, 2011, 10:01:18 AM12/27/11
to phon...@googlegroups.com, noor.awad, ka...@goiblue.com
Dear Sir,

I'm Amr Elgretly from BirdICT,

We are specialized in Mobile advertising, mainly mobile application development, SMS and Bluetooth advertising.

BirdICT wish you
  Merry Christmas and happy new year


Please, let me introduce our products to you,

{AdsBlue- iBlue(Long Arm2-Devices-Octopus-LiveCD)- PlusXMS)}



AdsBlue:

AdsBlue is a mobile brochure builder, which give you the ability to make a lot of amazing stuffs like:

 

·         Contact your customers and get new clients through the (Custom, Subscribe, Invite a friend and E-mail me) functions.

·         Put the URL of your (Facebook, twitter, videos, and website) and make your customer connected to you.

·         Add (Maps, menus, Pages, Search menus, Galleries), and you can put all that in on gallery.

·         Work on almost all mobile phones, iPhone, iPod, etc. through the (Smart link) which determine the appropriate extension for each mobile and send to it the best application

·         Your customers will receive the latest details and information through the (update function)

·         Keep your data with your customers all the time, where it will be on their mobiles

·         It's effective, especially at the cost side, where you will only create one application for all your customers.

·         The applications will be saved on client's mobiles.

·         It's clean and don't pollute the environment.

·         It's suitable for all mobiles.

·         It's easy to change and add contents at any time; even after finishing it.


Please visit our website for more information and details
CLICK HERE.

You can find some examples for our applications  
CLICK HERE.
They are arranged as following: Galleries, cars, stadiums, sport teams, tourism and commercial guide, weddings, services, Buildings, explaining for products and services, TV programs, Banks, and restaurants
.


Note: these applications only for mobiles that support java..... if you are interested ask for the smart link


This will be your solution to continue your admobile,
If you have more question please feel free to contact us.
Look for ward to hear from you

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
Amr Elgretly
a...@goiblue.com

ADSBLUE Build your own application
http://www.adsblue.com/en/


GSM : +2 01285807353
Skype: amr_elgretly 




-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
WARNING: This message and any attached files, in their entirety, are intended for the use of the individual and/or entity referenced above and may contain information that is privileged, confidential, and/or exempt from disclosure by applicable law or court order.

If the reader of this message is not the intended recipient, please notify the sender via the most expedient means available (relevant contact information precedes this notice).

Abhinav Sree

unread,
Dec 27, 2011, 10:06:47 AM12/27/11
to phon...@googlegroups.com
hey Dan,
can u give me a reference code, not able to get it done properly.

Abhinav Sree

unread,
Dec 27, 2011, 11:17:03 AM12/27/11
to phon...@googlegroups.com
Actually Dan thanks a lot, got it working.

Horst

unread,
Dec 28, 2011, 5:08:19 AM12/28/11
to phonegap
MillennialMedia offers a AdMob-Fallback. So you can try to add
MillenialMedia and get AdMob-Ads this way. MilleniamMedia also offer a
Server-API, which makes the ad handling much easier.

best regards
Horst

az

unread,
Jan 3, 2012, 5:12:27 AM1/3/12
to phonegap
Dan or Abhinav, can you post the code you used to
use the admob sdk? I was using the javascript
method, but it's no longer working.

thanks!
az


On Dec 28 2011, 2:08 am, Horst <ho...@klier.net> wrote:
> MillennialMedia offers aAdMob-Fallback. So you can try to add
> MillenialMedia and getAdMob-Ads this way. MilleniamMedia also offer a

Dan Shookowsky

unread,
Jan 3, 2012, 10:15:54 AM1/3/12
to phonegap
The code is nearly identical to the example code provided by admob. I
use the following code after my super.loadUrl call. You'll have to
add a view variable declarations at the class level as well. Note,
see the admob docs for required entries in the manifest.xml

// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);

// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = super.root; // this is the only change
from the sample

// Add the adView to it
layout.addView(adView);

// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();
//request.setTesting(true);

adView.loadAd(request);

On Jan 3, 5:12 am, az <alon...@gmail.com> wrote:
> Dan or Abhinav, can you post the code you used to
> use theadmobsdk?  I was using the javascript

Chetankumar Akarte

unread,
Jan 3, 2012, 1:21:48 PM1/3/12
to phonegap
Hey Dan!
Thanks for the code... Its works perfect. Its show ads @ the bottom of
the screen...

For Newbie...

You need to import widget class like...

import android.widget.LinearLayout;


My Complete code...


import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.ads.*;
import com.phonegap.*;

public class testActivity extends DroidGap {
private static final String MY_AD_UNIT_ID = "yourId";
private AdView adView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout layout = super.root; // this is the only change
from the sample
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());

az

unread,
Jan 3, 2012, 3:57:27 PM1/3/12
to phonegap
Thanks guys! With your help it was a piece of cake.

Note: I also had to increase the Project Build Target to at
least 13 to support some of the Manifest changes.

:]
az


On Jan 3, 10:21 am, Chetankumar Akarte <chetan.aka...@gmail.com>
wrote:
> > The code is nearly identical to the example code provided byadmob.  I
> > use the following code after my super.loadUrl call.  You'll have to
> > add a view variable declarations at the class level as well.  Note,
> > see theadmobdocs for required entries in the manifest.xml

Abhinav Sree

unread,
Jan 4, 2012, 2:47:14 AM1/4/12
to phon...@googlegroups.com

well chetan, if you want to display the ad at the top just load the ad before loading the URL

Chetankumar Akarte

unread,
Jan 4, 2012, 3:44:16 AM1/4/12
to phonegap
Abhinav Thanks!

Hi all,
I have one more question I wan to separate add unit and contents, How
can I do that?
When ads get serve on page, It allows me to scroll, but sometime it
become little tedious, so I want to separate and content.
Please take a look at my app... so you will get clear idea.
https://market.android.com/details?id=sahityachintan.theCallofTheWild

Thanks & Regards
Chetan Akarte
Message has been deleted

Gautam Chaudhary

unread,
Jan 12, 2012, 1:24:02 AM1/12/12
to phon...@googlegroups.com
Thanks a lot Dan!!

I was displaying the admob ads on top but couldn't figure out how to load them at bottom. Now its done!!

Thanks again!!

sentiense technologies

unread,
Jan 20, 2012, 12:54:47 AM1/20/12
to phon...@googlegroups.com
Hi,
I have replaced the above code and now I am getting "The field DroidGap.root is not visible" error. How to fix it?

Thanks in advance.


sentiense technologies

unread,
Jan 20, 2012, 7:56:57 AM1/20/12
to phonegap
Hi all,

Thanks for the information.

I have tried the above code but still I could not see any ad in the
page. Below is the code in my apps.
I am getting compilation error "The field DroidGap.root is not
visible".

import android.os.Bundle;
import android.widget.LinearLayout;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import com.phonegap.DroidGap;

public class HomePage extends DroidGap {
/** Called when the activity is first created. */
private static final String MY_AD_UNIT_ID = "My_Id";
private AdView adView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");

// LinearLayout layout = super.root; // this is the only change
from the sample
LinearLayout layout =
(LinearLayout)findViewById(R.id.mainLayout);

// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);

// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();
request.setTesting(true);

adView.loadAd(request);
}

Could any one help me out in fixing this. I have been trying to
include ads in my apps for last one week. I have more than one page in
the apps and I wish to include the ads in most of the pages. Please
throw some light on this too.

Thanks in advance

John Spounias

unread,
Jan 20, 2012, 11:34:53 AM1/20/12
to phonegap
After messing around with sencha touch panels for a week
unsuccessfully this fix worked for me in 20 minutes. Thanks for all
your hard work.

dave

unread,
Feb 13, 2012, 7:06:46 PM2/13/12
to phon...@googlegroups.com
I have this working, but everytime an ad is loaded, it pushes down the rest of my view.  Has anyone else experienced this?  I tried adding an onResume with:
super.loadUrl("javascript:window.location.reload();");
But the weird thing is that NEVER works the first time - the first time the view is rendered with a new ad.  But if I hit the home button, and then go back into the app, then it does the reload, and the layout is fine.  I've spent a couple days trying to figure out either why the newly loaded ad pushes down/messes up my layout, or at least how to get the onResume reload to work the first time.

Gonzalo

unread,
Apr 26, 2012, 3:15:54 PM4/26/12
to phon...@googlegroups.com
Hi, thanks a lot, this thread was very useful.
So if there any possibility of controlling the ad display by page? I mean, i want to display the ad in some pages but not in all.
Regards

Autinhorse

unread,
May 3, 2012, 9:50:58 AM5/3/12
to phon...@googlegroups.com
I met same problem and I googled web couldnot find right solution for it.
My main view showed first, after several seconds, adview showed and push main view down, it will give user very bad feeling.

I guess all people using Admob will not like it. Is there anyone meet this problem and have solution?

Thanks.
Reply all
Reply to author
Forward
0 new messages