Hello everyone!
I'm looking for some libraries for Ads and I'm testing some that I found on the forum.
Today I found an example of erel, he then updated the example showing how to start, but I have no knowledge of java, so I will try to gradually develop the lib.
Their SDK tutorial has some steps, the first was completed by Erel.
Now I'm in the second stage
This step says
To request an ad you should retrieve the placement object from the Controller.
Ok.
i made this
I was confused later
in their example application there is this.
And the documentation says
Here is what i made
but returned an error
which step did I not follow correctly? I created the listener and called the function that the tutorial is teaching.
I thank everyone, and remember that I have no knowledge of java.
thx
I'm looking for some libraries for Ads and I'm testing some that I found on the forum.
Today I found an example of erel, he then updated the example showing how to start, but I have no knowledge of java, so I will try to gradually develop the lib.
Their SDK tutorial has some steps, the first was completed by Erel.
Initializing the SDK
Before You Start Make Sure: At least one App and Placement are added on Developer Portal SDK is installed Initialise the SDK upon app start. In order to do so - within your app's main activity...
support.display.io
Now I'm in the second stage
Requesting and Loading Ads
Before You Start Make Sure: At least one App and Placement set up on Publisher Portal SDK is installed SDK is initialized Each Ad request has "Testing" status which enables it to test ...
support.display.io
This step says
To request an ad you should retrieve the placement object from the Controller.
Java:
Placement placement = Controller.getInstance (). GetPlacement (placementId);
i made this
B4X:
Private Placement As JavaObject
Placement = Controller.RunMethod("getPlacement", Array("7103"))
I was confused later
in their example application there is this.
AndroidSample/app/src/main/java/com/brandio/androidsample/InterstitialActivity.java at master · displayio/AndroidSample
Sample Android app demonstrating Display.io monetization SDK - displayio/AndroidSample
github.com
Java:
private void loadAd() {
loadButton.setEnabled(false);
Placement placement;
try {
placement = Controller.getInstance().getPlacement(placementId);
} catch (DioSdkException e) {
Log.e(TAG, e.getLocalizedMessage());
return;
}
AdRequest adRequest = placement.newAdRequest();
adRequest.setAdRequestListener(new AdRequestListener() {
@Override
public void onAdReceived(AdProvider adProvider) {
adProvider.setAdLoadListener(new AdLoadListener() {
@Override
public void onLoaded(Ad ad) {
loadedAd = ad;
showButton.setEnabled(true);
}
@Override
public void onFailedToLoad(DIOError error) {
Toast.makeText(InterstitialActivity.this, "Ad for placement " + placementId + " failed to load", Toast.LENGTH_LONG).show();
}
});
try {
adProvider.loadAd();
} catch(DioSdkException e) {
Log.e(TAG, e.getLocalizedMessage());
}
}
@Override
public void onNoAds(DIOError error) {
Toast.makeText(InterstitialActivity.this, "No Ads placement " + placementId, Toast.LENGTH_LONG).show();
}
});
adRequest.requestAd();
}
And the documentation says
Then issue a new AdRequest object from the Placement object using the newAdRequest() method.To retrieve previously issued AdRequests, you may use the getLastAdRequest() and getAdRequestById() methods.
To execute an Ad Request call the AdRequest object’s requestAd() method.
Apply AdRequestListener to your AdRequest object to get callback with AdProvider object that enables access to the retrieved ad.
Here is what i made
B4X:
Private AdRequest As JavaObject
AdRequest = AdRequest.InitializeStatic("com.brandio.ads.AdRequest")
Dim AdListener As Object = AdRequest.CreateEventFromUI("com.brandio.ads.listeners.AdRequestListener", "AD", Null)
AdRequest.RunMethod("setAdRequestListener", Array(AdListener))
AdRequest.RunMethod("requestAd", Null)
but returned an error
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
onInit
controller initialized
Error occurred on line: 62 (B4XMainPage)
java.lang.IllegalArgumentException: Expected receiver of type com.brandio.ads.AdRequest, but got java.lang.Class<com.brandio.ads.AdRequest>
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6608)
at android.view.View.performClickInternal(View.java:6585)
at android.view.View.access$3100(View.java:785)
at android.view.View$PerformClick.run(View.java:25921)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
which step did I not follow correctly? I created the listener and called the function that the tutorial is teaching.
I thank everyone, and remember that I have no knowledge of java.
thx