2

I add AdMob in my application using the following code.

<?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >
<com.google.ads.AdView 
    android:id="@+id/adview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER" 
    ads:adUnitId="ca-app-pub-*************************"
    ads:loadAdOnCreate="true"
    ads:testDevices="********************"
    />
 <TabHost
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        >

        <TabWidget
            android:id="@android:id/tabs"
            android:textSize="12sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </FrameLayout>
    </LinearLayout>
 </TabHost>
</LinearLayout>

The ad is displayed on my phone. However, it does not return to my app when I touch "Back" button. Instead, it returns to my phone web pages previously viewed. Any suggestions are welcome.

codingForFun
  • 113
  • 1
  • 15

5 Answers5

3

Please try this in your manifest

<activity android:name="com.google.ads.AdActivity"
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:noHistory="true">

Especially, 'noHistory'. It works for me.

putti
  • 46
  • 1
1

To me this is expected behaviour, as I have had this happen to me occasionally. Once the user clicks on the ad, the back button is tied to whatever application is then opened. It's normally either Google Play or your phone's browser.

In Google Play clicking back will typically take you straight back to your app. However, in your browser, pressing back will either take you back to your last previously viewed pages (like pressing back in a browser), or if there isn't any, then back to your app.

Once the user clicks the ad, control of the back button is out of your hands, really.

Badgerati
  • 171
  • 3
  • The strange thing is that I cannot use my app anymore. If I click my app, it would go the ad web page. How can I use my app after clicking the ad? – codingForFun Dec 18 '13 at 16:58
0

When clicking the admob ad, the Internet browser app on the whole is launched and not just one activity that shows a webpage. That's the reason your app sits below the Internet browse in the stack just as badgerati said.. To throw more highlight to the matter, when you launch gallery application to view the image (from your app) only the Vies Image activity fires up and not the whole galary app hence when you click back you return to your app.. But unluckily the things are not same with browsers

Mihir Solanki
  • 308
  • 2
  • 11
  • In my test device, clicking an ad will go to the play store. Then, I click Back button, it still stuck in the play store. It is not Browser. – codingForFun Dec 18 '13 at 17:04
  • I see my app screen flashed for a second and then it returned to the play store. – codingForFun Dec 18 '13 at 17:13
  • Did you try testing it on some other device? – Mihir Solanki Dec 18 '13 at 17:23
  • I tested on my phone, Samsung Galaxy S 3. Then, I tested on emulator a few minutes ago. On Samsung Galaxy S 3, clicking "Back" button will flash my app screen, then go back to Play store. On the amulator, my app screen will appear as very small screen in the lower bottom of the emulator with ads screen as background. If I click that small screen, my app returns correctly. – codingForFun Dec 18 '13 at 17:39
  • Seems bit odd.. I suggest you to delete that activity and xml files related to that activity and have a fresh start with that section of your app.. That helps sometimes – Mihir Solanki Dec 18 '13 at 17:45
  • I changed from Admob Android SDK to Google Play services for ads. The problem was gone. However, I still do not understand the problem. – codingForFun Dec 18 '13 at 18:20
  • Me neither nvm just kudos to problem solved.. You might want to email admob android sdk helpline for notifying them about this prob – Mihir Solanki Dec 19 '13 at 08:06
  • Hi, codingForFun. I have the same problem: after clicking on Smaato or Appodeal ads that causes to open a browser tab, I cannot return to my Main Activity because my App gets stuck in the browser window. Have you found any effective solution yet? (Changing your advertisement provider doesn't really count...) – Carlos Botero Jan 11 '19 at 14:56
0

It sounds like you may have misconfigured one of the Application or Activity attributes in your AndroidManifest. Something like launchMode, noHistory, allowTaskReparenting, etc.

Post your AndroidManifest.

William
  • 20,150
  • 8
  • 49
  • 91
0

That happened to me when I had 'Don't save activities' checked in Settings|Developers Options. If unchecked (as it normally should be) everything works fine.

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158