Rewarded video ad resume method - android

I'm implementing rewarded video on an application in c++ on ios and android, but the crash happened only on android. It happens only sometimes, when it comes from background to foreground.
I got the message Abort message: 'rewarded_video::Initialize() must be called before this method.' on crash report, and I think it`s when the resume method from the rewarded video is called.
Does anybody knows if I have someway of knowing if resume is supposed to be called? Or should it be called whenever the app enters foreground?
Thanks in advance,
Felipe.

I found out what the problem was. My app on android was creating another instance when opened from another source, and that was causing the error message on the rewarded video.
I added android:launchMode="singleTask" on the manifest and it worked.

Related

AdMob's RewardedVideoAd destroys activity it was started from after video is watched

I am using AdMob's RewardedVideoAd.
What I've done is when user opens a chat activity, I ask him to view a video to be able to chat to another user (by simply switching visibility of the chat elements). Then, after the video is watched, I make the chat elements visible.
It works well on the emulator. However, when I tested it on my phone, the chat activity is closed after video is watched. I cannot understand why this is happening.
It only happens if a user watches the video till the end (onRewarded() is called).
Any suggestions?
Ok, I worked it out.
It happened, because I did not forward the lifecycle events. After I called resume(context), pause(c), destroy(c) according to my Activity lifecycle, it worked.
God knows why it worked fine on the emulator and did not on my phone.

AdMob Rewarded Video Ad Screen Orientation

I have a "trivia" kind of game which only allows user to play in "Portrait" orientation. As you know, android activities automatically restarted when the orientation changes.
My game asks 20 questions to user in a randomized order. And there is a button that the user can get "hints" with watching rewarded video ads. However, AdMob sends "Landscape" videos, sometimes. And for that reason, after the video has finished, my activity starts from the 1st question, again.
How can I restrict AdMob from sending "Landscape" orientated video ads? I could not find anything on AdMob help page. Or, can I make it via coding? I am sure that restart thing is about orientation change because when AdMob sends "Portrait" Ads, game goes well from where it was before the video.
Thanks for your help!
Add "configChanges" property in the activity tag in "AndroidManifest" to prevent "activity" from restarting due to orientation change caused by the intersitial video.
watching rewarded video ads start a new Activity then your Activity will be in background and when your video finished or close your Ad then your paused Activity come in foreground.
So don't worry about your App start from beginning. Make sure you're not calling onDestroy() on your Activity and having all appropriate configuration in Manifest file.
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/BJ9XGyDMGHk

Admob interestitial causes app to close

I'm trying to integrate Admob interstitial ads to my android app and for some reason. Every time I open an ad it calls my activity onDestroy method witch results on my app being closed without any log-cat errors or messages.
Does anyone knows what may be causing my app to close once Admob interstitial is opened ?
Thanks in advance.
Android closes processes if needed when an application enters the background. You need to be able to handle the destruction of the activity. Look into saving instance states HERE

Admob ads displaying but click through doesn't work

I'm using the GoogleMobileAdsSdkAndroid.zip (Version 6.4.1), with android-13 specified as the target in project.properties in Eclipse.
When I was developing and testing the app, I was using adMob in test mode. The ads loaded, displayed and refreshed ok. However, when I clicked on an ad, it didn't click through. A window opens very very briefly but immediately closes and my app resumes again (it looks like the onResume method is called from a brief inspection).
I thought that this was just due to it being in test mode, so I pushed my app out to Google Play anyway with testing turned off.
However, testing it on a friend's phone, it does exactly the same thing.
Any ideas gratefully received?
Thanks.
Cracked it! The AdMob Activity and the main activity for my app have to run in the same process. I had specified a particular process in the main activity for my app in the AndroidManifest.xml, but hadn't specified the same process in the AdMob activity. As soon as I did that, all is working.
.
I deleted the following code from onUnifiedNativeAdLoaded method and problem solved!
if (unifiedNativeAd!= null) {
unifiedNativeAd.destroy();
}

application crashes if it is in idle

i am working on an application.The first screen having login.After launching the application in device and playing with it is all ok and not any issue at all.
but if at the same time user opens any other application,uses it for a while and closes this second application and then again navigate to previously open application(on which i am working),and tries to tap or manipulate or login on the application ,application gets crashed. why so behaviour?
i am facing this issue very first time and no any idea of this.
any suggestion?
Thanks.
Check out the Android app lifecycle: http://developer.android.com/reference/android/app/Activity.html.
My guess is the Activity that your user is coming back in to is overriding the onResume() method and the method is throwing an exception or you're not calling super.onResume(). That's my best guess without any more details on what your code is doing or information from your logCat.

Categories

Resources