You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to create a android library from huawei ads sdk i've tried everything i can imaging but banner doesn't show up.
note: i'm testing on nox player and your example apk work fine on this nox player,
this my code:
public class AdaptiveBanner {
private FREContext context;
private FrameLayout frameLayout;
private BannerView hwBannerView;
boolean initialLayoutComplete = false;
int height;
int total;
int ColorValue;TextView textView;
public void setContext(FREContext ctx) {
this.context = ctx;
}
public void showAdaptiveBanner(String bannerKey, String position) {
hwBannerView = new BannerView(context.getActivity());
hwBannerView.setAdId("testw6vs28auh3");
hwBannerView.setBannerAdSize(BannerAdSize.BANNER_SIZE_320_50);
hwBannerView.setBannerRefresh(30);
hwBannerView.setBackgroundColor(Color.BLUE);
textView = new TextView(context.getActivity());
height = AdaptiveBannerHeight();
int total = height;
if (initialLayoutComplete == false) {
FrameLayout.LayoutParams pa = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, total);
ColorValue = Color.BLACK;
if (position.trim().equals("BOTTOM") || position.trim().equals("bottom") || position.trim().equals("Bottom")) {
pa.gravity = Gravity.BOTTOM;
} else {
pa.gravity = Gravity.TOP;
}
frameLayout = new FrameLayout(context.getActivity());
frameLayout.setBackgroundColor(ColorValue);
context.getActivity().addContentView(frameLayout, pa);
textView.setText("Banner Ad");
textView.setTextSize(16);
textView.setGravity(Gravity.CENTER);
textView.setTextColor(Color.WHITE);
frameLayout.addView(textView);
// Create LayoutParams for the hwBannerView
FrameLayout.LayoutParams bannerParams = new FrameLayout.LayoutParams(
BannerAdSize.BANNER_SIZE_320_50.getWidthPx(context.getActivity()),BannerAdSize.BANNER_SIZE_320_50.getHeightPx(context.getActivity()));
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
frameLayout.addView(hwBannerView, bannerParams);
frameLayout.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (!initialLayoutComplete) {
initialLayoutComplete = true;
loadBanner(bannerKey); // Call loadBanner after the layout is complete
}
}
});
}
}
private void loadBanner(String bannerKey) {
hwBannerView.setAdListener(adListener);
AdParam adParam = new AdParam.Builder().build();
hwBannerView.loadAd(adParam);
}
public AdListener adListener = new AdListener() { @Override
public void onAdLoaded() {
// Called when an ad is loaded successfully.
Toast.makeText(context.getActivity(), "inside onAdLoaded", Toast.LENGTH_LONG).show();
}
@Override
public void onAdFailed(int errorCode) {
String msg = String.valueOf(errorCode);
// Called when an ad fails to be loaded.
Toast.makeText(context.getActivity(), msg, Toast.LENGTH_LONG).show();
}
@Override
public void onAdOpened() {
// Called when an ad is opened.
Toast.makeText(context.getActivity(), "inside onAdOpened", Toast.LENGTH_LONG).show();
}
@Override
public void onAdClicked() {
// Called when an ad is clicked.
Toast.makeText(context.getActivity(), "inside onAdClicked", Toast.LENGTH_LONG).show();
}
@Override
public void onAdLeave() {
// Called when an ad leaves an app.
Toast.makeText(context.getActivity(), "inside onAdLeave", Toast.LENGTH_LONG).show();
}
@Override
public void onAdClosed() {
// Called when an ad is closed.
Toast.makeText(context.getActivity(), "inside onAdClosed", Toast.LENGTH_LONG).show();
}
};
public int AdaptiveBannerHeight() {
return BannerAdSize.BANNER_SIZE_320_50.getHeightPx(context.getActivity());
}
public void Hide() {
// banner_view.removeAllViews();
}
}
note:
i've tried using XML Source file too but nothing same result, i give it height and background color just to debug if bannerview show up in my activity. i've tried build banner before initial the layout too but same result too no banner ad, sometime it's gives me code error 4 and sometimes 3, i think it's just when time to refreshing the ad it calls the listeners.
interstitial work fine,
i've added necessary declarations needed for huawei ads jar's and resources in xml file
thank you Huawei Support
The text was updated successfully, but these errors were encountered:
Edit:
now i downgrade version from 13.4.66.300 to 13.4.62.302, to can add the missing ads-template jar and it resources, and now i get a close ad button but there is no ads on banner, and when i click on that close button the app crash.
i'm trying to create a android library from huawei ads sdk i've tried everything i can imaging but banner doesn't show up.
note: i'm testing on nox player and your example apk work fine on this nox player,
this my code:
public class AdaptiveBanner {
private FREContext context;
private FrameLayout frameLayout;
private BannerView hwBannerView;
boolean initialLayoutComplete = false;
int height;
int total;
int ColorValue;TextView textView;
public void setContext(FREContext ctx) {
this.context = ctx;
}
public void showAdaptiveBanner(String bannerKey, String position) {
}
note:
thank you Huawei Support
The text was updated successfully, but these errors were encountered: