Admob ads displaying but click through doesn't work - android

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();
}

Related

OnCreate is called multiply when app is started from Play Store App first and then from home screen

It occurred to me that under some circumstances our app seems to be restarted from scratch after being backgrounded. I managed to track to issue down to MainActivity.OnCreate being called multiply under the following circumstances
App is installed from APK and then ran from the installer, after backgrounding the app and starting it from the home screen it's reset to scratch
This behavior persists until the app is killed and then restarted from the home screen
App is run from Google Play app, after backgrounding the app and starting it from the home screen it's reset to scratch
If the app is backgrounded and then started from Play Store it's started correctly
App is run from home screen, after backgrounding the app and starting it from Google Play it's reset to scratch
When the app is foregrounded from the same launcher it has been started initially, OnCreate is not called again. There is at least one question reporting a similar behavior, unfortunately there is no answer providing a solution for the behavior.
When MainActivity.OnCreate is called, the instance of MainActivity seems to be a different instance than the initial one, since private members that are set in OnCreate are null when I'm trying to log them, anyway, the application context does not seem to be recreated from scratch, because AppCenter seems to be initialized right away on the second run, Xamarin.Forms starts up way quicker and static variables keep their values.
Is there any way to prevent this behavior and just keep a single instance of MainActivity active?
Congratulations! You've been bit by a long-standing, nasty Android bug which has been around since the dawn of time and is still broken, even though countless issues have been opened about it and the behaviour is reproducible and well-documented.
See the following:
https://issuetracker.google.com/issues/36907463
https://issuetracker.google.com/issues/36941942
https://issuetracker.google.com/issues/64108432
Re-launch of Activity on Home button, but...only the first time
App restarts rather than resumes
In September 2019, one of these issues was marked "fixed" with this comment:
Thanks for reporting this issue. The issue has been fixed and it will
become available in a future Android release.
So hopefully we will no longer be seeing this in Android Z ;-)
There is a workaround documented in my answer to
Re-launch of Activity on Home button, but...only the first time
in your android manifest set on the activity tag
android:launchMode="singleTop"
It will have consequences on how you handle notifications, and in some cases onActivityResult

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

Prevent an app to show on recent application list on android kitkat 4.4.2

I was just bored of iOS and I recently changed to Android. I have a Nexus 5 device, and I've just finished installing my favourite apps in my device.
One of those apps is Line, the famous communication app from naver. I installed it and I configured it with a passcode in order to secure access to it, so no one despite me could see the "confidential" conversations inside.
The problem is even if I have the passcode enabled on line, if someone presses the "Recent list applications" button, they can see perfectly a screenshot of Line with my last conversation, so anyone could see what I was doing in Line.
I made the same test on iPhone and .. surprise ... iOS is taking the snapshot AFTER the passcode screen is enabled, so anyone could see nothing. It seems that in Android the snapshot is taken BEFORE passcode screen is enabled so anyone could see what last line screen looks like :)
So, having read other threads on this forums, I'm supposed to have several ways to solve this:
Wait for LINE's company NAVER to add an option to prevent this app to show on recent app list (adding android:excludeFromRecents="true" on THEIR manifest) [that won't be soon]
Wait for LINE's company NAVER to force the snapshot after passcode screen is enabled [maybe soon but not in company'sroadmap]
Decompile apk and change manifest on my own - or use FLAG_SECURE - (I tried it but when I launch the new app it suddenly dies on startup with a message "Application stopped". I thing LINE's server verifies on startup that the client app is what is expected to be, comparing sizes or something else)
So I don't know more ways to get around this. Do you have any more idea? I'm stucked on it.
Thank you a lot.
Detect when LINE has left foreground
Create a background service that detects if LINE is on foreground and when it leaves the foreground. (https://stackoverflow.com/a/14044662/1683141)
When line has left foreground, you should take action:
A. Stop the line app completely
OR
B. Open & "close" the line app so it will show a locked state in the multitask thumbnail
A possible way to accomplish situation B:
Optionally: detect which app the user has now opened and remember it
Wait a few seconds and open the LINE app again after the user closed it (by intent for example)
Now the LINE app will show the lock screen
Now let the background service open the home screen (or make an intent to the remembered activity)
Now the LINE app is back to the background and it will have a multitask-thumbnail showing the locked screen.
Ofcourse, this will create a loop, and this isn't a stable solution
-Option A is a relatively reliable, and a (in my opinion) good way to accomplish what you want: no one can see your secure chat. Disadvantage is that the application is now removed from multitasking.
-Option B is only an idea, but maybe, if it's done the right way, It could work.
Edit: Option A will not work. The application will not be removed from multitasking if the task is killed.

how to disable error messaging android

Problem:
I am working with custom UI, now. There are some threads inside a program. Sometimes system shows message that my app has stopped. But it's false in my case. My app instantly restores itself and keeps working so everything is just fine.
Question:
Is there a way to disable any system messages appearing?
I am new in android and will be really grateful for some advice.
(edit)
Well so i found the following. App crushes on start after it was "closed" by hardware "<-- Back" button. Not every time only sometimes. When i select it in menu of opened apps once more it opens normally and runs just fine. Is there a way to remove that "crush" message? sure i do understand that app has crushed and its not good at all.

Signed apk does not keep the app in background

My issue is like this, I press home button and go to home page, then I press the app icon to get back to the app. Instead of resuming the app it starts from the beginning. But if I select app from recent app list, it resumes. So, some unknown reason app starts from the beginning if I press app icon.
I'm getting this strange result with signed apk. Unsigned/debug apk works fine, it resumes.
Please note that, I've not handled any BackStack activities, neither handled any activity android:launchMode.
At last I'm answering my own question. The issue is solved.
It turned out that Activity Standard LaunchMod (which is default settings) behaves like this in Some devices with OS v5.0 +. So, I added it to be "launchMode" in from menifest. So App works fine now. Although I'm still not sure about this behavior.

Categories

Resources