Mopub banner ads - better control of loading/unloading - java

I want to have fine control over a MoPub banner ad which appears over the top of my game app screen at specific times and not at others. My code currently looks like this (simplified):
LinearLayout linearlayout_for_banner = new LinearLayout (this);
mAdView = new MoPubView(this);
linearlayout_for_banner.addView(mAdView);
The linearlayout_for_banner is transparent, so when there is no advert, the user can see all of the game-play screen underneath. Then at a certain precise point I wish an ad to appear. At the moment, the only function I know to call is mAdView.loadAd() which as far as I know begins a process of going to the internet to seek an ad, then if it finds one it will be drawn on the screen. This is very unsatisfactory, because there is often a delay before it appears. So what I would like are functions like scoop_an_advert_but_dont_show_it_yet() and now_show_that_ad_you_scooped_earlier(). Do they exist? Mopub's documentation seems rather inadequate on this.

Try browsing their github wiki: https://github.com/mopub/mopub-client/wiki/CustomEventsAndroid
You want their, "onReceiveAd" method. Check it out, seems like exactly what you need.

There's no problem with preloading ads and not showing them until a specific time. You can use loadAd() for this. Just swap the visibility of the view when you want it to appear.
NOTE: If you do, you should set that particular ad to not "refresh every x seconds" on the mopub site. Otherwise, it will end up as unintentional ad fraud, since the ad will be refreshing itself while invisible(not to mention tank your CTR).
If you have other ads running in the app without this requirement, I'd recommend a separate ad unit for your sometimes-invisible one, so you can still do the refresh on the other one.

Related

Admob interstitial ad in LibGDX shows banner?

I am trying to display an interstitial in LibGDX after the title screen. I implemented the official github code: https://github.com/TheInvader360/tutorial-libgdx-google-ads/commit/0a5ea376d4eb92b8e87c13a03245adb40b53e811
The code is working fine but I think I'm missing something because whenever I call the showOrLoadInterstital() function, it displays a banner. I want to display a full screen ad instead.
In the code I see an adView being initialized with settings for a banner, but the mentioned function showOrLoadInterstital() uses the InterstitialAd, which is correct. As a beginning game developer (but not beginning developer in general), I am not getting the hang of this, especially those two different ad types together.
Could someone tell me what I am missing here? Should showOrLoadInterstital() just not show a full ad when I call it in my Game class?
Thanks.

Android Changing activity by onTouch like a book

I am a student trying to create tales/story app. I am wanting change the activity when the user swipes right it will go to the next page and when the user swipes left it will go back to the previous page. I have been viewing examples however I am still confused how to do so. Would anyone be able to point me in the right direction?
Instead of having one activity for each page, just replace new content on the same activity.
https://github.com/MysticTreeGames/android-page-curl. Page curl.
Page curl with renderscript.
http://code.google.com/p/renderscript-examples/wiki/PageCurl. The link has a video of pagecurl demo.
The source code in available at http://code.google.com/p/renderscript-examples/source/browse/#svn%2Ftrunk%2FPageCurl.
Details regarding renderscript at http://developer.android.com/guide/topics/renderscript/index.html.
Here's a video on renderscript talk by Romain guy. http://www.youtube.com/watch?v=5jz0kSuR2j4.
You might need to use page curl effect kind of projects to achieve that like this or this . The way you think of making use of activities might not be a good idea. Because if you just make activities for each page, then it is not guaranteed that they would still exist if you come back as it increases burden on the back stack and the system would automatically destruct the activities if it requires some resources to be allotted for other things. Or you can create your own effects.

One layout over another at run time?

My game app has many complex graphical elements and I am worried that having a banner ad continuously on screen will detract too much from the game. My plan is that the user will be able to play each "level" in the game using the full screen without any ads, but upon completion of each level an ad will slide in, on top of the top part of the screen. Presumably this means I have to somehow create a layout programatically that will appear on top of the existing screen layout. Can this be done? If so how?
It can be done.
Afaik you simply have to create a layout which is android:backgroundcolor="transparent".
Else you could do it so you started a new activity on each level completion?

Android - Honeycomb or ICS Go Completely Full Screen

Is there a way in ICS or Honeycomb to go completely full screen? I want the system UI completely gone! Currently what I do is:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
But this results in the Status Bar being replaced by really dim dots! I want it completely gone! Lets say for example I want to play a video or show a picture that takes up the whole screen. I'm okay with the status bar coming back on user interaction but I need it completely gone when there is no user interaction.
With the code above. I get the following look:
I want the dim dots gone as well and my video / image to be completely full screen.
This is not possible in Honeycomb, but has been added in API v14. Use:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
See the more detailed answers over here (though I would use a Build.Version.SDK_INT check instead of the suggested reflection-based check for support):
Hide ICS back home task switcher buttons
As the previous poster Suggested, that is completely impossible without rooting your device and performing some somewhat dirty process kill operations. The reason for is that new Hardware (like a tablet, for instance) may not have hardware buttons for navigation - and so by hiding those buttons the User would have no means of doing things that they are supposed to be guaranteed to be able to do, like going to the home screen, or accessing device info. Whether or not you might agree with that reasoning, such is the API.
The last information I have is that you can use the black tape to cover it. That's the suggestion given by Chet Haase. Watch this google IO 2011 session Q&A starting at 53minutes
You want SYSTEM_UI_FLAG_HIDE_NAVIGATION . Keep in mind that since the soft navigation buttons are key to device experience this only hides the buttons until there is some user interaction. If you want to permanently hide them then rooting the device (as others have suggested) is the only way to go.
The flag was added as of Ice Cream Sandwich, API 14. Previous to 14 a flag STATUS_BAR_HIDDEN was added in Honeycomb, API 11 that had a similar function. Previous to that the soft navigation buttons didn't exist, so fullscreen modes were handled entirely by Themes (specifically Theme.NoTitleBar.Fullscreen).
Use:
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
mBaseLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
else if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB )
mBaseLayout.setSystemUiVisibility( View.STATUS_BAR_HIDDEN );

Android: Creating a Scrollable Layout

I'm trying to create a "scrollable" layout in Android. Even using developers.android.com, though, I feel a little bit lost at the moment. I'm somewhat new to Java, but not so much that I feel I should be having these issues--being new to Android is the bigger problem right now.
The layout I'm trying to create should scroll in a sort of a "grid". I THINK what I'm looking for is the Gallery view, but I'm really lost as to how to implement it at the moment. I want it to "snap" to center the frame, like in the actual Gallery application.
Essentially, if I had a photo gallery of 9 pictures, the idea is to scroll between them up/down AND side to side, in a 3x3 manner. Doesn't need to dynamically adjust, or anything like that, I just want a grid I can scroll through.
I'm also not asking for anyone to give me explicit code for it--I'm trying to learn, more than anything. But pointing me in the right direction for helpful layout programming resources would be greatly appreciated, and confirming if it's a Gallery view I'm looking for would also be really helpful.
EDIT: To clarify, the goal is to have ONE item on screen at a time. If you scroll between one item and the next, the previous one leaves the screen, and the new one snaps into place. So if it were a photo gallery, each spot on the grid would take up the entire screen size, approximately, and would be flung out of the viewable area when you slide across to the next photo, in either direction. (Photos are just an example for illustration purposes)
This page gives a good summary of the different built in layout objects. From your description a GridView or possibly a TableLayout might work. GalleryView looks to be horizontal only.
I believe GridView is what you're looking for. Here's a tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html
You should check out the ViewPager widget, which is available in the Android compatibility package. I spent a loooong time trying to get the Gallery widget to behave properly, but finally settled on a ViewPager which returned ImageView objects instead. Works like a charm.

Categories

Resources