简体   繁体   English

如何在Android中检测WebView或浏览器

[英]how to detect webview or browser in android

I'm going to detect webview or browser in android I want to display a banner in Android browsers. 我要在Android中检测Webview或浏览器,但要在Android浏览器中显示横幅。 Which users click to install app. 哪些用户单击以安装应用程序。 And I do not want to display this banner on the webview android. 而且我不想在webview android上显示此横幅。

I use this: 我用这个:

    <?php
     if ($_SERVER['HTTP_X_REQUESTED_WITH'] == "app.mypackage") {
      echo 'WebView'; }
      else {
     echo 'no-WebView';
     }
   ?>

But that does not work, and displays the 'webview' in browser and webview app 但这不起作用,并在浏览器和Webview应用程序中显示“ webview”

There is another way to do this? 还有另一种方法吗?

Not accurate but you could use Javascript to check the platform that the site is running on using: 不准确,但是您可以使用Javascript使用以下方法检查网站运行的平台:

navigator.platform

Possible result(s) of using this property will include: 使用此属性的可能结果将包括:

  • HP-UX HP-UX
  • Linux i686 Linux i686
  • Linux armv7l (Android) Linux armv7l(Android)
  • Mac68K Mac68K
  • MacPPC MacPPC
  • MacIntel MacIntel
  • SunOS 在SunOS
  • Win16 Win16的
  • Win32 Win32的
  • WinCE WinCE的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM