Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7087061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:37:38+00:00 2026-05-28T07:37:38+00:00

I am trying to display an advertisement using Greystrip in AndEngine. I cannot figure

  • 0

I am trying to display an advertisement using Greystrip in AndEngine.

I cannot figure out how this is done because it doesnt use a Layout to inflate views, but yet sprites.

i use BaseGameActivity to create my application for each scene i would like to display adds on.

In GreyStrip this is how they tell you to integrate ads in your application..

Before adding calls in your application to GSSDK, you need to
incorporate the SDK into your AndroidManifest.xml. Add the following
in the section, replacing
with a package identifier that is unique to your application. This
Content Provider manages local storage of ad content, while the
Activity manages ad display.

 <provider android:name="com.greystripe.android.sdk.AdContentProvider"
    android:authorities="<YOUR_APPLICATION_PACKAGE>.AdContentProvider"
android:multiprocess="true"
android:exported="false" />
<activity android:name="com.greystripe.android.sdk.AdView"
android:configChanges="keyboard|keyboardHidden|orientation" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

To initialize the Greystripe SDK, call the initialize method at
startup. This should be done within your application’s onCreate()
method. This call will spawn a background thread to initialize our
activity, and then return control to your app. In this background, the
Greystripe activity will download ads as well as any SDK updates.
Parameters: ctx: Your application Context instance appId: Use the
appId provided during app registration. Providing an invalid appId
will cause the SDK to display error notification ads.

 public static GSSDK initialize(Context ctx, String appId)

To use a banner, place the following in your main.xml file:

<view class="com.greystripe.android.sdk.BannerView"
android:id="@+id/gsBanner"
android:layout_width="320dp"
android:layout_height="48dp"/>

To reference the banner view in code, use findViewById, as with any
main.xml element:

BannerView myBanner = (BannerView) findViewById(R.id.gsBanner);

To request adds call

myBanner.refresh();

Now the problem is since i dont have an xml layout i cant figure out how i inflate the layout for the ad view?

Anyone have any ideas?

EDIT:

Ive seen someone do it like this in a tutorial online, but how can i inflate this in andengine?

try {
    String applicationId = Utils.scrapeIgnoreCase(externalParams, "<param name=\"id\">", "</param>");           
    GSSDK.initialize(context, applicationId);

    BannerView myBanner = new BannerView(context);          
    myBanner.setLayoutParams(view.getLayoutParams());
    myBanner.addListener(new GreyStripeBannerListener());           
    view.addView(myBanner);
    myBanner.refresh();
    myBanner.setOnClickListener(new  View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Click();
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:37:39+00:00Added an answer on May 28, 2026 at 7:37 am

    I’m using AdMob but it should be similar.

    Like @Sergey Benner referenced, you have to override onSetContentView in your activity, then create the RenderSurfaceView and your ad view manually.

    First of all, create a FrameLayout to contain AndEngine’s view and the ad view.
    Add AndEngine’s view and create your ad view, then set the frame layout as the content view.

    @Override
    protected void onSetContentView() {
        //Creating the parent frame layout:
        final FrameLayout frameLayout = new FrameLayout(this);
        //Creating its layout params, making it fill the screen.
        final FrameLayout.LayoutParams frameLayoutLayoutParams =
                new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
                        FrameLayout.LayoutParams.FILL_PARENT);
    
        //Creating the banner view.
        BannerView bannerView = new BannerView(this);
    
        //....
        //Do any initiallizations on the banner view here.
        //....
    
        //Creating the banner layout params. With this params, the ad will be placed in the top of the screen, middle horizontally.
        final FrameLayout.LayoutParams bannerViewLayoutParams =
                new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
                        FrameLayout.LayoutParams.WRAP_CONTENT,
                        Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    
        //Creating AndEngine's view.
        this.mRenderSurfaceView = new RenderSurfaceView(this);
        mRenderSurfaceView.setRenderer(mEngine, this);
    
        //createSurfaceViewLayoutParams is an AndEngine method for creating the params for its view.
        final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
                new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());
    
        //Adding the views to the frame layout.
        frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
        frameLayout.addView(bannerView, bannerViewLayoutParams);
    
        //Setting content view
        this.setContentView(frameLayout, frameLayoutLayoutParams);
    }
    

    Place this method in your BaseGameActivity class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to figure out how to display a advertisement on a
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I've been trying to display text using a Quartz context, but no matter what
Im trying to display a loading gif before submitting a multipart-form (file upload), this
Im trying to display this listview, but I keep getting a: 07-17 21:14:22.233: ERROR/AndroidRuntime(349):
im trying to display things inline using css that should be right next to
I'm trying to display a list of labels and inputs using JQuery Mobile so
I am trying to display a modal viewController in an iPad app using the
I am trying to display an .svg file in a HTML page using jQuery
i am trying to display an image from net..and i am using ignition library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.