我如何可以检测到一个Android应用程序在模拟器中运行? [英] How can I detect when an Android application is running in the emulator?

查看:359
本文介绍了我如何可以检测到一个Android应用程序在模拟器中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有我的code运行略有不同的仿真器设备上运行时比运行时。 (例如,使用,而不是一个公开的网址10.0.2.2反对开发服务器自动运行。)什么是当一个Android应用程序在模拟器中运行,以检测的最佳方法是什么?

I would like to have my code run slightly differently when running on the emulator than when running on a device. (For example, using 10.0.2.2 instead of a public URL to run against a development server automatically.) What is the best way to detect when an Android application is running in the emulator?

推荐答案

一个常用的一种SEMS是 Build.FINGERPRINT.startsWith(通用)

One common one sems to be Build.FINGERPRINT.startsWith("generic")

这篇关于我如何可以检测到一个Android应用程序在模拟器中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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