Android Question Any news about Native Ads Advanced?

asales

Expert
Licensed User
Longtime User
Hi @Erel
I have several Native Ads Express in my apps and the existing units will stop serving ads on March 1, 2018 (https://developers.google.com/admob/android/native-express).

The new Native Ads Advanced is available now and I can create this Ads (I think the information in page "Native is currently in a closed beta with a limited group of publishers" is out of date), but I don't have a option in FirebaseAdmob library to use it, only NativeExpressAd.



Any news about when we can get the updated FirebaseAdmob library?

Thanks in advance for your attention about this issue.
 

sorex

Expert
Licensed User
Longtime User
I don't mind that it is still in beta (I don't have any app using it) but I can understand that some people who rely on the old native ads
are about to pull their hairs out because their ads won't show up anymore and they don't have the replacement yet.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
It's interesting that on this page (https://support.google.com/admob/answer/7527424) they advise Native Ads Express users to convert their ads to Banner Ads - unless you're eligible for the Native Ads Advanced beta program. There's a pretty obvious timing issue here...

- Colin.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I want to put this sub (LoadNativeAd) in a separate static code module (NativeAd) and call it in others activities, like this:
NativeAd.LoadNativeAd

So, how I can change this line to match the current activity module name, that calls the sub, and not the Main module:
".main$MyAdListener"
B4X:
Listener.InitializeNewInstance(Application.PackageName & ".main$MyAdListener", Array("NativeAd"))  'change 'main' with the current activity module name
?
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
My guess would be that you change ".main$MyAdListener" to ".[activity name]$MyAdListener".

- Colin.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I think this it too, but I don't know how I can get the [activity name] that calls the sub in the NativeAd module.
Oh - I guess I'm not understanding the question then.

Wouldn't you just use the name of the activity that you are requesting the ad from? For example, if you are calling it from an activity named "Settings", wouldn't you just use ".settings$MyAdListener", then put an implementation of the listener in your Settings activity?

- Colin.
 
Last edited:
Upvote 0

asales

Expert
Licensed User
Longtime User
I want a way to call the code (NativeAd.LoadNativeAd with some parameters) in any activity, without put an implementation of the listener in all this activities.

Example:
- I have 5 activities with Native Express Ads.
- I created a code module (NativeAd) with this sub LoadNativeAd
- In sub Activity_Create of activity1 I call this line: NativeAd.LoadNativeAd
- I call the same line in acitivities 2, 3, 4 and 5.

If I use the ".main$MyAdListener" the native ads is not show.
I want to figure out a way to pass the name the activity that calls the NativeAd.LoadNativeAd: ".[activity name]$MyAdListener"

Did you understanding the question?
Sorry, but english is not my first language and I am learning.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Yeah - OK, now I understand.

Using ".main$..." will only work if the main activity is active. I guess you could try putting the listener in a class module or a service & then use ".[class / service]$..." - but from what little I know about listeners, I think they have to be implemented in an Activity (but I could be wrong).

- Colin.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks!
I'll stop with this implementation, for a while, because I put the code "LoadNativeAd" in a static code module and I get this error: Static code module cannot handle events.
in this line:
Wait For (builder) ContentAdLoaded_Event (MethodName As String, Args() As Object)

Maybe the solution is create a class module, but I think there is more complex to do it.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I made a change in this part of the Erel's original code, because the logo is not mandatory in the assets of the Content Ad, but the image is.

B4X:
'check if the logo image exists, otherwise upload large image
Dim logo As JavaObject = NativeContentAd.RunMethod("getLogo", Null)
Dim logoView As Panel = pAdmob2.GetView(1)  'I create a layout in Designer and get the views
If logo.IsInitialized Then
   logoView.Background = logo.RunMethod("getDrawable", Null)
   NativeContentAdView.RunMethod("setLogoView", Array(logoView))
Else
   Try
       Dim images As List = NativeContentAd.RunMethod("getImages", Null)
       If images.IsInitialized And images.Size > 0 Then
           Dim image As JavaObject = images.Get(0)
           logoView.Background = image.RunMethod("getDrawable", Null)
           NativeContentAdView.RunMethod("setImageView", Array(logoView))
       End If
   Catch
       Log(LastException)
   End Try
End If

This is an ad that uses the logo (if exists in the assets):


This is an ad that uses the big image, if the logo image don't exists in the assets:


This ad uses the logo (if available) and big image in the same layout, like the old native express ad (the big format):
 
Upvote 0

asales

Expert
Licensed User
Longtime User
There is a way to implement pause and resume in this native ads (like the old native express ad)?

The reason is that I call the LoadNativeAd sub in Activity_Create, when I create a UltimateListView with cells with ads.
If I click in a button to start another activity and the native ad is not load, when I return to the previous activity, the ads are not reload.

In the original code to Firebase Admob Native Express Ads:
https://www.b4x.com/android/forum/t...ated-with-firebase-backend.67710/#post-430383
there are this code, but I don't know how to implement it and call it in the Activity_Resume and Activity_Pause
B4X:
/**
 * Sends a request to AdMob, requesting an ad.
 */
public void LoadAd() {
    com.google.android.gms.ads.AdRequest req = new com.google.android.gms.ads.AdRequest.Builder().build();
    getObject().loadAd(req);
}

/**
 *Should be called from Activity_Pause.
 */
public void Pause() {
    getObject().pause();
}

/**
 *Should be called from Activity_Resume.
 */
public void Resume() {
    getObject().resume();
}
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
How do i implement the native ads code in my project. Any example of the source code will help.
There are a number of examples (with code) in this thread. Just look back through it & you'll see them.

- Colin.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
the admob sended me this email.


english: you need put mediaview on your native ads,later 29 of October, native ads without mediaview will be removed, will not show more ads.
the mediaview is important to show images OR videos.
my question is, what is mediaview on b4a? it is imageview or is another one? and how put this media view on native ads?
i found mediaview for b4j but b4a?
thx
 
Last edited:
Upvote 0

SMOOTSARA

Active Member
Licensed User
Longtime User


Hello dear colin

Please attach an example
If this example is a b4a program and it's all Soros, it's better
I thank you
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hello dear colin

Please attach an example
If this example is a b4a program and it's all Soros, it's better
I thank you
Nope - I gave up on Native Ads because they had a negative impact on revenues in the apps I implemented them in. There are plenty of examples in this thread if you go back & look at them.

- Colin.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…