Java Question Banner cannot be cast to android.view.View

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.

I'm trying to use the Display io SDK to make a library.
I've already managed to do all the interstitial part, but now in the banner I got to a part that I don't know how to follow.


Java:
public void onLoaded(Ad ad) {
    switch (adUnitType){
        case "BANNER" :{
            try {
                BannerPlacement bannerPlacement = (BannerPlacement) Controller.getInstance().getPlacement(placementId);
                View bannerView = bannerPlacement.getBanner(BannerAndMediumRectangleActivity.this, adRequest.getId());
                adLayout.addView(bannerView);
                adLayout.setVisibility(View.VISIBLE);
            } catch (DioSdkException e) {
                Log.e(TAG, e.getLocalizedMessage());
            }
            break;
        }

I m already get the onLoaded event, but i dont know how transform a banner to view.

B4X:
Sub adLoadBanner_Event (MethodName As String, Args() As Object) As Object
    Log(MethodName) '= onLoaded
    Log(Args.Length) '= 1
    If MethodName = "onLoaded" Then
        Private v As View = Args(0) '< CRASH HERE
    Else if MethodName = "onFailedToLoad" Then
        Log("error: " & Args(0))
    End If
    Return Null
End Sub

The code above cause a crash, here is the log.


what would be the correct way to transform the banner into a view?

Here is the java example

And here is this part on the sdk tutorial

Edit: I've already tried get it as javaobject and later add it to activity, but show me the same log....

Thank you!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…