Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying Ad In AndEngine
    primarykey
    data
    text
    <p>I am trying to display an advertisement using Greystrip in AndEngine.</p> <p>I cannot figure out how this is done because it doesnt use a Layout to inflate views, but yet sprites.</p> <p>i use BaseGameActivity to create my application for each scene i would like to display adds on.</p> <p>In GreyStrip this is how they tell you to integrate ads in your application..</p> <blockquote> <p>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.</p> </blockquote> <pre><code> &lt;provider android:name="com.greystripe.android.sdk.AdContentProvider" android:authorities="&lt;YOUR_APPLICATION_PACKAGE&gt;.AdContentProvider" android:multiprocess="true" android:exported="false" /&gt; &lt;activity android:name="com.greystripe.android.sdk.AdView" android:configChanges="keyboard|keyboardHidden|orientation" &gt; &lt;intent-filter&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <blockquote> <p>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.</p> </blockquote> <pre><code> public static GSSDK initialize(Context ctx, String appId) </code></pre> <blockquote> <p>To use a banner, place the following in your main.xml file:</p> </blockquote> <pre><code>&lt;view class="com.greystripe.android.sdk.BannerView" android:id="@+id/gsBanner" android:layout_width="320dp" android:layout_height="48dp"/&gt; </code></pre> <blockquote> <p>To reference the banner view in code, use findViewById, as with any main.xml element:</p> </blockquote> <pre><code>BannerView myBanner = (BannerView) findViewById(R.id.gsBanner); </code></pre> <p>To request adds call</p> <pre><code>myBanner.refresh(); </code></pre> <p>Now the problem is since i dont have an xml layout i cant figure out how i inflate the layout for the ad view?</p> <p>Anyone have any ideas?</p> <p>EDIT:</p> <p>Ive seen someone do it like this in a tutorial online, but how can i inflate this in andengine?</p> <pre><code>try { String applicationId = Utils.scrapeIgnoreCase(externalParams, "&lt;param name=\"id\"&gt;", "&lt;/param&gt;"); 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(); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload