asales Expert Licensed User Longtime User Mar 13, 2020 #1 In this link: Global settings | Android | Google for Developers Configure global settings for Google Mobile Ads SDK (Legacy) for Android. developers.google.com I have this code to mute the sound of ads: B4X: Copy MobileAds.setAppMuted(true); How I can made this in B4A, because I saw only the method Initialize in MobileAds? Thanks in advance for any tip.
In this link: Global settings | Android | Google for Developers Configure global settings for Google Mobile Ads SDK (Legacy) for Android. developers.google.com I have this code to mute the sound of ads: B4X: Copy MobileAds.setAppMuted(true); How I can made this in B4A, because I saw only the method Initialize in MobileAds? Thanks in advance for any tip.
Pendrush Well-Known Member Licensed User Longtime User Mar 13, 2020 #2 You may try something like this: B4X: Copy 'Dim MobileAds As MobileAds 'MobileAds.Initialize Dim volume As Float = 0.5 Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppVolume", Array(volume)) or B4X: Copy Dim mute As Boolean = True Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppMuted", Array(mute)) Last edited: Mar 13, 2020 Upvote 0
You may try something like this: B4X: Copy 'Dim MobileAds As MobileAds 'MobileAds.Initialize Dim volume As Float = 0.5 Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppVolume", Array(volume)) or B4X: Copy Dim mute As Boolean = True Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppMuted", Array(mute))
asales Expert Licensed User Longtime User Mar 13, 2020 #3 Thanks. It works, but this code: B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize initialize the mobile ads with the "Admob App ID" in the manifest. There is no problem if I use several RunMethod? I can use like this? B4X: Copy jo.RunMethod("initialize", Array(ctxt, "ca-app-pub-3940256099942544~3347511713")) 'Sample ID jo.RunMethod("setAppVolume", Array(volume)) jo.RunMethod("setAppMuted", Array(mute)) or I can initialize the MobileAds and initialize another JavaObject to set the AppMuted? B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize Dim MobileAds2 As JavaObject MobileAds2.InitializeStatic("com.google.android.gms.ads.MobileAds") MobileAds2.RunMethod("setAppMuted", Array(True)) Last edited: Mar 13, 2020 Upvote 0
Thanks. It works, but this code: B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize initialize the mobile ads with the "Admob App ID" in the manifest. There is no problem if I use several RunMethod? I can use like this? B4X: Copy jo.RunMethod("initialize", Array(ctxt, "ca-app-pub-3940256099942544~3347511713")) 'Sample ID jo.RunMethod("setAppVolume", Array(volume)) jo.RunMethod("setAppMuted", Array(mute)) or I can initialize the MobileAds and initialize another JavaObject to set the AppMuted? B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize Dim MobileAds2 As JavaObject MobileAds2.InitializeStatic("com.google.android.gms.ads.MobileAds") MobileAds2.RunMethod("setAppMuted", Array(True))
Erel B4X founder Staff member Licensed User Longtime User Mar 15, 2020 #4 It is a static method so it is not tied to any specific object. Pendrush code is correct. Upvote 0
asales Expert Licensed User Longtime User Mar 16, 2020 #5 Erel said: It is a static method so it is not tied to any specific object. Pendrush code is correct. Click to expand... So, If I put the Admob App ID in the manifest and use this code: B4X: Copy jo.InitializeStatic("com.google.android.gms.ads.MobileAds") I don't need this code: B4X: Copy jo.RunMethod("initialize", Array(ctxt, "ca-app-pub-3940256099942544~3347511713")) Correct? Upvote 0
Erel said: It is a static method so it is not tied to any specific object. Pendrush code is correct. Click to expand... So, If I put the Admob App ID in the manifest and use this code: B4X: Copy jo.InitializeStatic("com.google.android.gms.ads.MobileAds") I don't need this code: B4X: Copy jo.RunMethod("initialize", Array(ctxt, "ca-app-pub-3940256099942544~3347511713")) Correct?
Erel B4X founder Staff member Licensed User Longtime User Mar 16, 2020 #6 You need to initialize it as explained here: https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/ You don't need to call initialize with JavaObject. Upvote 0
You need to initialize it as explained here: https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/ You don't need to call initialize with JavaObject.
asales Expert Licensed User Longtime User Mar 16, 2020 #7 I'm a little bit confused. So, my final code will be this (in Starter): B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize Dim mute As Boolean = True Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppMuted", Array(mute)) Upvote 0
I'm a little bit confused. So, my final code will be this (in Starter): B4X: Copy Dim MobileAds As MobileAds MobileAds.Initialize Dim mute As Boolean = True Dim jo As JavaObject jo.InitializeStatic("com.google.android.gms.ads.MobileAds") jo.RunMethod("setAppMuted", Array(mute))