#AdditionalJar: adcolony
#AdditionalJar: androidx.appcompat:appcompat
#AdditionalJar: com.google.android.gms:play-services-ads-identifier
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
Private AdColony As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
AdColony.InitializeStatic("com.adcolony.sdk.AdColony")
Dim ctxt As JavaObject
ctxt.InitializeContext
AdColony.RunMethod("configure", Array(ctxt, "app id", Array As String("zone id"))) '<----------
RequestInterstitial
End Sub
Sub RequestInterstitial
Dim listener As JavaObject
listener.InitializeNewInstance(Application.PackageName & ".main$MyAdColonyInterstitialListener", Null)
AdColony.RunMethod("requestInterstitial", Array("zone id", listener)) '<----------
End Sub
Sub AdColony_OnRequestFilled (Ad As Object)
Log("OnRequestFilled")
Log(Ad)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#if Java
import com.adcolony.sdk.*;
public static class MyAdColonyInterstitialListener extends AdColonyInterstitialListener {
public void onRequestFilled(AdColonyInterstitial ad) {
main.processBA.raiseEventFromUI(null, "adcolony_onrequestfilled", ad);
}
}
#End If
CreateResourceFromFile(Macro, Core.NetworkClearText)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddApplicationText(<activity android:name="com.adcolony.sdk.AdColonyInterstitialActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true"/>
<activity android:name="com.adcolony.sdk.AdColonyAdViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true"/>)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName: 1.0.0
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#AdditionalJar: adcolony
#AdditionalJar: androidx.appcompat:appcompat
#AdditionalJar: com.google.android.gms:play-services-ads-identifier
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private AdColony As JavaObject
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim appid As String = "app6e40d81b1cc84c4891"
Dim zoneid As String = "vz6c2d7e01d0f849cf9e"
Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Log("start")
Activity.Color=Colors.Red
AdColony.InitializeStatic("com.adcolony.sdk.AdColony")
Dim ctxt As JavaObject
ctxt.InitializeContext
AdColony.RunMethod("configure", Array(ctxt, appid, Array As String(zoneid))) '<----------
Button1.Initialize("Button1")
Activity.AddView(Button1,10%x,50%y,80%x,12%y)
End Sub
Sub Button1_Click
RequestInterstitial
End Sub
Sub RequestInterstitial
Dim listener As JavaObject
listener.InitializeNewInstance(Application.PackageName & ".main$MyAdColonyInterstitialListener", Null)
AdColony.RunMethod("requestInterstitial", Array(zoneid, listener)) '<----------
End Sub
Sub AdColony_OnRequestFilled (Ad As Object)
Log("OnRequestFilled")
Log(Ad)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#if Java
import com.adcolony.sdk.*;
public static class MyAdColonyInterstitialListener extends AdColonyInterstitialListener {
public void onRequestFilled(AdColonyInterstitial ad) {
main.processBA.raiseEventFromUI(null, "adcolony_onrequestfilled", ad);
}
}
#End If
Logger connected to: asus ASUS_X00LD
--------- beginning of main
** Activity (main) Pause, UserClosed = false **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
start
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
start
** Activity (main) Resume **
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@e453ed3
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@d72ef7d
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@972976c
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@25e5c17
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@23a46e
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@2754321
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@9065a0
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@c923f1b
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@1955f82
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@9962ffc
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@ac3902c
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@95977d7
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@bca6f2e
OnRequestFilled
com.adcolony.sdk.AdColonyInterstitial@a3378e1
** Activity (main) Pause, UserClosed = false **
right. @Erel wrotenow you need to call the routine to display it
If you see OnRequestFilled in the logs then we can progress.
Sub AdColony_OnRequestFilled (Ad As Object)
Log("OnRequestFilled")
Log(Ad)
dim addColony As JavaObject = Ad
addColony.RunMethod("show", Array()))
End Sub
right. @Erel wrote
You can try this untested Code (note i´m not so good in JavaObject!)
B4X:Sub AdColony_OnRequestFilled (Ad As Object) Log("OnRequestFilled") Log(Ad) dim addColony As JavaObject = Ad addColony.RunMethod("show", Array()) End Sub
Sub RequestAdView
Dim size As JavaObject
size = size.InitializeStatic("com.adcolony.sdk.AdColonyAdSize").GetField("BANNER") '320dip x 50dip
Dim listener As JavaObject
listener.InitializeNewInstance(Application.PackageName & ".main$MyAdColonyAdViewListener", Null)
AdColony.RunMethod("requestAdView", Array(zoneid, listener, size)) '<----------
End Sub
Sub AdColony_AdView_OnRequestFilled (Ad As Object)
Log("AdColony_AdView_OnRequestFilled ")
Log(Ad)
Dim v As View = ad
Activity.AddView(v, 0, 0, 320dip, 50dip)
End Sub
#if Java
import com.adcolony.sdk.*;
public static class MyAdColonyAdViewListener extends AdColonyAdViewListener{
public void onRequestFilled(AdColonyAdView adview) {
main.processBA.raiseEventFromUI(null, "adcolony_adview_onrequestfilled", adview);
}
}
#End If
#if Java
import com.adcolony.sdk.*;
public static class MyAdColonyAdViewListener extends AdColonyAdViewListener{
public void onRequestFilled(AdColonyAdView adview) {
main.processBA.raiseEventFromUI(null, "adcolony_adview_onrequestfilled", adview);
}
public void onClicked(AdColonyAdView adview) {
main.processBA.raiseEventFromUI(null, "adcolony_adview_onclicked", adview);
}
}
#End If
Untested code:
B4X:Sub RequestAdView Dim size As JavaObject size = size.InitializeStatic("com.adcolony.sdk.AdColonyAdSize").GetField("BANNER") '320dip x 50dip Dim listener As JavaObject listener.InitializeNewInstance(Application.PackageName & ".main$MyAdColonyAdViewListener", Null) AdColony.RunMethod("requestAdView", Array(zoneid, listener, size)) '<---------- End Sub Sub AdColony_AdView_OnRequestFilled (Ad As Object) Log("AdColony_AdView_OnRequestFilled ") Log(Ad) Dim v As View = ad Activity.AddView(v, 0, 0, 320dip, 50dip) End Sub #if Java import com.adcolony.sdk.*; public static class MyAdColonyAdViewListener extends AdColonyAdViewListener{ public void onRequestFilled(AdColonyAdView adview) { main.processBA.raiseEventFromUI(null, "adcolony_adview_onrequestfilled", adview); } } #End If
What resources should I use to know the methods and classes of this library?
AdColony advertising library
Hello friends:) Which is the best and new " AdColony advertising library " for b4a ?www.b4x.com
i did found the show method using their site and followed the links on their site.
Do not remember exactly where.
We cannot help you with this information...