点击广告会打开浏览器,但是我无法返回到Android应用程序的启动活动屏幕 [英] Clicking on an ad opens a browser, but I cannot go back to the launching activity screen of my Android app

查看:241
本文介绍了点击广告会打开浏览器,但是我无法返回到Android应用程序的启动活动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使这里有类似的情况:

Even though there is a similar case here:

点击AdMob广告后,我无法通过后退按钮返回到我的Android应用程序

建议的代码无法解决我的情况。因此,如果有人有新想法解决此问题,我将发布此信息。

the code proposed didn't solve my case. So I am posting this if there's somebody with fresh ideas to solve this.

我已经为Android编写了一个应用程序。现在,我正在尝试向此应用添加广告。
我正在实施Appodeal的广告。当我在主要活动中显示一种称为MREC的广告类型时,如果单击广告中的
,它将在设备的默认浏览器中打开一个标签。

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.

当我按下设备上的方形按钮(显示当前正在运行的应用程序的菜单)时出现问题:它显示浏览器,
也是我自己的应用程序处于活动状态。如果选择我的应用程序,Android不会让我的应用程序走在前列,而是显示设备背景或最近打开的
浏览器。就像浏览器已经接管了我应用的身份一样。

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?

另一件事是,在Appodeal提供的示例应用程序中,onResume中没有代码,并且与清单中的
Appodeal SDK,但从浏览器选项卡发出后,该应用程序正确返回到主活动。我也在尝试实施Admob广告,并且会发生与本博文中所述相同的效果。

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.

推荐答案

已解决!我在此页面上实施了用户的建议:AngraX:

Solved! I implemented the advice by the User: AngraX from this page:

如何在Android中做到这一点。活动-> Web浏览器-> Acrivity,但按Back键后看不到WebBrowser

他建议在其中将其添加到应用程序清单文件中的Main Activity声明中:

where he recommends to add this to the Main Activity declaration in the Manifest file of your App:

  android:allowTaskReparenting="true"
  android:launchMode="singleTask"

它有效!在我的应用程序中的Smaato广告在设备的默认网络浏览器中启动标签后,无论返回是否通过以下三种方式之一完成,我现在都可以返回到我的主活动:

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:


  1. 通过按返回按钮必要的次数返回主活动屏幕,无论您是从应用程序还是从浏览器中按返回按钮

  1. 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

通过单击应用程序屏幕上的关闭(X)按钮

By clicking the close (X) button on the screen of your App

通过按下Android设备的方形按钮(菜单按钮),然后选择您的应用

By pressing the square button of your Android device (Menu Button), and then choosing your App

这篇关于点击广告会打开浏览器,但是我无法返回到Android应用程序的启动活动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆