Reputation: 1425
I have a strange problem. The most of the times my ads cant be clicked on. The strange thing is that sometimes you can!! if you cant click on the ad , then the logcat shows the following message:
W/Ads ( 477): Unable to check for AdMob redirect.
W/Ads ( 477): java.net.MalformedURLException: Protocol not found: /default2.aspx?lang=EN&gclid=CKa_39L4ua0CFWIntAod92Dc_Q
W/Ads ( 477): at java.net.URL.<init>(URL.java:275)
W/Ads ( 477): at java.net.URL.<init>(URL.java:159)
W/Ads ( 477): at h$a.a(Unknown Source)
W/Ads ( 477): at h$a.doInBackground(Unknown Source)
W/Ads ( 477): at android.os.AsyncTask$2.call(AsyncTask.java:185)
W/Ads ( 477): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/Ads ( 477): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/Ads ( 477): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
W/Ads ( 477): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
W/Ads ( 477): at java.lang.Thread.run(Thread.java:1096)
Since the apps can sometimes be clicked , I dont think there is anything wrong with my code. But just to be sure:
public class Ad {
private AdView adView;
protected String id = MY_AD_ID;
RelativeLayout adsLayout;
public Ad(Window window,Context context) {
adsLayout = new RelativeLayout(context);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
adsLayout.setGravity(Gravity.BOTTOM);
adView = new AdView((Activity) context, AdSize.BANNER,id );
if(window != null) // to be clear this is needed for when I want to creat an ad in a AlertDialog ;)
adsLayout.addView(adView);
AdRequest newAdReq = new AdRequest();
adView.loadAd(newAdReq);
if(window != null)
window.addContentView(adsLayout,lp2);
}
public AdView getAd() {
return adView;
}
public void newAd() {
adView.loadAd(new AdRequest());
}
public int getHeight() {
return adView.getHeight();
}
public void removeView() {
((ViewGroup) adsLayout.getParent()).removeView(adView);
}
}
Greetings!
Upvotes: 1
Views: 254
Reputation: 8931
The code looks fine. Is this your own ad that you are trying to click? It looks like the click url on the ad is wrong; if it is indeed /default2.aspx?lang=EN&gclid=CKa_39L4ua0CFWIntAod92Dc_Q
, then it is not a valid web url, and is the source of the error.
Upvotes: 1