After click AdMob ads, I cannot return to my Andro

2019-07-13 22:37发布

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.

5条回答
男人必须洒脱
2楼-- · 2019-07-13 23:16

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.

查看更多
做个烂人
3楼-- · 2019-07-13 23:27

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.

查看更多
Anthone
4楼-- · 2019-07-13 23:28

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.

查看更多
祖国的老花朵
5楼-- · 2019-07-13 23:31

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

查看更多
三岁会撩人
6楼-- · 2019-07-13 23:39

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.

查看更多
登录 后发表回答