I have an app which has an activity-A. I am showing an Interestial Ad from Admob in it. This is achieved using the Google play services. When there is a weak signal, when I clicked the home button in middle of the app, I could see the home screen. Now when I again clicked the app, the app freshly starts (instead of continuing from the place where i left) and when I close the app using the close button which actually calls the finish() statement and closes the app. But after closing the app the app continuous the activity from the first place where i have pressed the home button which Is very strange to me. Kindly help me to resolve this
This is not happening when I have full internet signal / no signal.
Related
Even though there is a similar case here:
After click AdMob ads, I cannot return to my Android app by back button
the code proposed didn't solve my case. So I am posting this if there's somebody with fresh ideas to solve this.
I have coded an app for Android. Now I am trying to add ads to this app.
I am implementing the ads from Appodeal. When I show an ad type called MREC (which is a square-like banner) on my main activity, if I click
on the ad, it will open a tab in the default browser of the device.
The problem arises when I press the square button on the device (the menu that displays the current running apps): it displays the browser and
also my own app as active. If I select my app, Android wont let my app come to the forefront, instead it shows the device background or the
recently opened browser. It's like the browser has taken over the "identity" of my app.
So, why I cannot return to the activity screen where the ad is located, and from where the click launched a browser tab?
One more thing is that in the sample apps that Appodeal provide, there is no code in onResume, and there isn't any different code from the
Appodeal SDK in the manifest, and yet, the app returns correctly to the main activity after coming from the browser tab. I am also trying to implement Admob ads, and the same effect happens as described in this post.
Solved! I implemented the advice by the User: AngraX from this page:
How can I do that in Android. Activity -> WebBrowser -> Acrivity, but Press Back not see the WebBrowser
where he recommends to add this to the Main Activity declaration in the Manifest file of your App:
android:allowTaskReparenting="true"
android:launchMode="singleTask"
And it works! After the Smaato ad in my App launches a tab in the default web browser of the device, I am now able to return to my Main Activity, no matter if the returning is done in any of these 3 ways:
By pressing back button the necessary number of times to return to the Main Activity screen, no matter if you press back button from your App or from the browser
By clicking the close (X) button on the screen of your App
By pressing the square button of your Android device (Menu Button), and then choosing your App
I am making a fitness app. During the rest period of fixed time I am showing ads using AdMob. If a user clicks on the ad then the app opens up browser/playstore. When the user clicks on back the browser/playstore closes and the user comes back to my app. But my app doesn't realize this and remains frozen. The rest period does not reduce. Only on clicking the app, does the app know that it is active. Is there a way to tell the app to continue once back is pressed after an admob ad is clicked?
When your app loses focus everything is paused. Override onResume method in your activity to restart what ever appears to be paused as per their normal behavior or you have explicitly pauses in onPaused method.
I have similar problem like this.
On start my app displays a splash screen and checks via network if the current user is still premium.
My problem: I started my app right before I went to bed and minimized it by pressing the home button. In the morning I launched the app again and it resumed the activity from the night. The app never really quit, my splash screen was not shown and and it couldn't check if the user is still premium.
So how can I achieve my app to be closed after a certain time (e.g. when the app is minimized)?
But the problem is there is a portion in the app where I can view videos in full screen and here I use android's default player. So when the app is minimized while watching and then again open the app onResume will not be called and cannot check whether it is a registered user or not. The video player will continue to play the video. Is there any method so that I can kill the app when the video is playing and minimised?? is there any method which is called when the app is minimised using home key press?? Is it possible in every device to detect the home keypress event and write some code there?? Please help with some fresh ideas!!!
Now I know why my reputation is always low. Thanks Dan Hulme. You are right I just want to use the app lifecycle correctly. I want to use onRestart not onResume. And that have done the work for me. Thanks all.
When some users click an ad on my app and they are done viewing the ad, and want to come back to the app, if they hit the back button the control goes to the home screen but the app does not crash because they see it running in the background.
I am not overwriting the default behavior of the controls.
What could be causing this or is it the expected behavior ?
This is not expected behaviour.
If they are definitely pressing the back button (and not the home button), then it sounds like the intent that displayed the Play Store has been configured to start the Activity in a new Task. Unfortunately, there isn't anything you can do do about this except raise it with the ad network in question.
I have successfully added admob ads to my android app and can view test ads on the emulator and my development phone (Nexus One). When I click on one of the test ads, it opens the web browser or market to that particular page(gmail or whatever). I click the home button to exit, but when I try to start my app again, it takes me back to the market page or browser that came up when clicking the test ad.
I have a feeling it is something in the onLeaveApplication or onPresentScreen methods implemented with AdListener, but I'm lost and the adMob documentation doesn't provide much info on this.
Generally this is the expected behavior for an application. If you click home and then back on your application icon, most applications will jump back to the last activity on the stack. It's certainly possible to kill your application altogether and treat re-entry as a brand new instance of your application, but you probably don't want that either as all user state will be lost unless you explicitly save it, which is even more work.
The AdMob client SDK listener callbacks are all optional for you to implement; there's no expectation that you do anything in particular. They're there as a convenience for you to pause, save, or resume whatever activity you were doing before.
Users are generally used to hitting the back button to go back to your app, not home and then back into the app.