After click AdMob ads, I cannot return to my Android app by back button
Asked Answered
M

5

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.

Mead answered 18/12, 2013 at 16:33 Comment(0)
B
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.

Bridgers answered 31/12, 2013 at 18:3 Comment(0)
E
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.

Extravagance answered 18/12, 2013 at 16:50 Comment(1)
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?Mead
P
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

Parsnip answered 18/12, 2013 at 16:57 Comment(8)
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.Mead
I see my app screen flashed for a second and then it returned to the play store.Mead
Did you try testing it on some other device?Parsnip
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.Mead
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 sometimesParsnip
I changed from Admob Android SDK to Google Play services for ads. The problem was gone. However, I still do not understand the problem.Mead
Me neither nvm just kudos to problem solved.. You might want to email admob android sdk helpline for notifying them about this probParsnip
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...)Quartan
T
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.

Tiliaceous answered 18/12, 2013 at 22:21 Comment(2)
I do not have any options except name and label.Mead
<application android:name="com.***.***.***" android:icon="@drawable/***" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.***.***.***" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.**.**.**" android:label="@string/app_name"></activity>Mead
O
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.

Oversee answered 5/1, 2014 at 20:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.