[英]How to know whether my App is running on Bluestacks?
I'm working on a special version of my App which should run in Bluestacks . 我正在研究应用程序的特殊版本,它应该在Bluestacks中运行。 It's a windows/mac application which allows to run Android apps on the computer.
它是一个Windows / mac应用程序,允许在计算机上运行Android应用程序。
I would like to implement special behaviour when the app runs in Bluestacks. 当应用程序在Bluestacks中运行时,我想实现特殊行为。 Nothing complicated, maybe showing a dialog or disabling some buttons.
没有什么复杂的,可能会显示一个对话框或禁用一些按钮。
But for that purpose I need to know whether the app is running on a Bluestacks device. 但为此我需要知道该应用程序是否在Bluestacks设备上运行。 I checked the device model (
Build.MODEL
) and manufacturer ( Build.MANUFACTURER
), but I get that the device is a Samsung GT i900. 我检查了设备型号(
Build.MODEL
)和制造商( Build.MANUFACTURER
),但我得知该设备是Samsung GT i900。
Does someone know an unambiguous way to know whether an app is running on Bluestacks? 有人知道一个明确的方法来了解应用程序是否在Bluestacks上运行?
I know it´s rather a quite localized question, but it would be fine if I get some ideas about where to look at, or what to try. 我知道这是一个非常本地化的问题,但如果我得到一些关于在哪里查看或尝试什么的想法,那就没关系了。
Try this: 尝试这个:
/**
* Returns true if device is Android port to x86
*/
public static boolean isx86Port()
{
String kernelVersion = System.getProperty("os.version");
if(kernelVersion != null && kernelVersion.contains("x86")) // for BlueStacks returns "2.6.38-android-x86+"
return true;
return false;
}
Finally I decided to build a new app for Bluestacks using an Android library. 最后,我决定使用Android库为Bluestacks构建一个新的应用程序。 This allows me to add special behaviour for the bluestacks app.
这允许我为bluestacks应用程序添加特殊行为。
I tried to get all the info using the Build
class, but it returns the same as a Samsung Galaxy GT i9000 device, so it's impossible to know that the device is running in bluestacks. 我尝试使用
Build
类获取所有信息,但它返回的功能与Samsung Galaxy GT i9000设备相同,因此无法知道设备是否正在bluestack中运行。
尝试以下代码:
File test = new File("/data/Bluestacks.prop"); boolean isRunningInBluestacks = test.exists();
This Will be unique. 这将是独一无二的。
There is no bluetooth device in Bluestack. Bluestack中没有蓝牙设备。
So try to get The Bluetooth Address string which is always 'null' on Bluestack or Any emulator.Make sure you are adding Bluetooth permission on your project manifest. 因此,尝试在Bluestack或Any模拟器上获取始终为“null”的蓝牙地址字符串。确保在项目清单上添加蓝牙权限。
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.