Webbrowser with advertising

19 views
Skip to first unread message

rdvg...@gmail.com

unread,
May 11, 2018, 5:22:31 PM5/11/18
to CodenameOne Discussions
Hi,

I want to place advertising in the southern part of my app and that it is repeated in all forms in the same way that admod does it. I thought about putting a Webbrowser component and call a page that has a carload of images or animations (as they are done by Google Web Designer) but that the size of them was a maximum of 320 x 50px.

I have some questions:
1. How do I make webBrowser run in all forms of my app?
2. I did a test by placing a webBrowser in the southern part of a form and to my surprise the web Browser was showing covering the center and south of the form. Projecting 320 x 50 images can correct this problem?
3. Is there another way to do what I want?

I imagine that already someone in the forum had the need to do this, I appreciate your comments.

Shai Almog

unread,
May 12, 2018, 12:50:05 AM5/12/18
to CodenameOne Discussions
Hi,
there are two parts to this. First we have the global aspect of the question to which the answer is no.
Admob leveraged some internal hidden functionality which is frankly flaky as hell. I would suggest avoiding that. The simple thing to do would be deriving the Form class and implementing your own Form class. Then concentrate the common functionality in that Form subclass. Use a Container for the main functionality and place it above the ad.

The reason using SOUTH doesn't work has to do with preferred size. It will work worse on the device where the ad won't show at all.

SOUTH in border layout gives the component its preferred height and the screen width. You would have 3 options to fix that:

- Use setPreferredSize

- Override calcPreferredSize in BrowserComponent (which can gives you the ability to vary height between portrait/landscape)

- Use table layout and add two components with the appropriate height & width constraints so they fill up the form correctly.
Reply all
Reply to author
Forward
0 new messages