I would like to ascertain at run-time inside an Android app whether it is running within the BlueStacks Android emulator. This is so I can modify the way the app runs when running inside BlueStacks.
我想在运行时确定一个Android应用程序是否在BlueStacks Android模拟器中运行。这样我就可以修改应用程序在BlueStacks内部运行时的运行方式。
BlueStacks does not support multi-touch so I want to implement an alternative to the standard pinch-to-zoom functionality my current app has.
BlueStacks不支持多点触控,所以我想要实现我目前的应用程序中标准的pinchto -zoom功能。
E.g.
如。
If (appIsRunningInBlueStacks){
mySurfaceView.enableMultiTouchAlternatives();
} else{
mySurfaceView.enableMultiTouchFeatures();
}
What is a reliable way of ascertaining the value of appIsRunningInBlueStacks?
什么是确定appIsRunningInBlueStacks价值的可靠方法?
EDIT Summary of answers to comments on question:
编辑对问题评论的回答摘要:
Ben, Taras, thanks for the suggestions. The Build.MODEL etc. values for BlueStacks are:
Ben, Taras,谢谢你的建议。构建。蓝色标记的值为:
-
Model: "GT-I9100"
模型:“GT-I9100”
-
Manufacturer: "samsung"
制造商:“三星”
-
Device: "GT-I9100"
设备:“GT-I9100”
-
Product: "GT-I9100"
产品:“GT-I9100”
This is the same model number as the Samsung Galaxy SII so it would not be ideal to use this for fear of treating all users with SIIs the same as those on BlueStacks.
这是与三星Galaxy SII相同的型号,因此使用它并不理想,因为担心会将所有用户都与BlueStacks相同。
CommonsWare, the app continues to run in BlueStacks even with the < uses-feature> for multitouch in the manifest. In fact (also answering iagreen's question)...
CommonsWare,即使在清单中有< uses-feature>的多点触控功能,该应用仍然继续以蓝色标记运行。事实上(也回答了iagreen的问题)……
packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
... returns true! This is to be expected I suppose as the emulator is convinced it is a Samsung Galaxy SII!
…返回true !我想这是意料之中的,因为模拟器相信它是三星Galaxy SII!
Therefore we are still without a way of reliably detecting whether an app is running on BlueStacks without also throwing all Samsung Galaxy SII users in the same bucket. Any other ideas?
因此,我们仍然无法可靠地检测应用程序是否运行在BlueStacks上,同时也无法将所有三星Galaxy SII的用户扔进同一个水桶里。任何其他想法?
5 个解决方案
#1
2
You can check that the Bluestacks shared folder exist /sdcard/windows/BstSharedFolder
您可以检查Bluestacks共享文件夹是否存在/sdcard/windows/BstSharedFolder
Boolean onBlueStacks()
{
File sharedFolder = new File(Environment
.getExternalStorageDirectory().toString()
+ File.separatorChar
+ "windows"
+ File.separatorChar
+ "BstSharedFolder");
if (sharedFolder.exists())
{
return true;
}
return false;
}
#2
1
My version of BlueStacks is reporting my Build.Model
as GT-N7100
.
我版本的BlueStacks是报告我的构建。GT-N7100模型。
Using: android.opengl.GLES20.glGetString(android.opengl.GLES20.GL_RENDERER)
I get Bluestacks
.
使用:android.opengl gles20 . glgetstring (android.opengl gles20 . gles20 . gl_renderer)我获得了Bluestacks。
#3
0
It maybe too late but for the sake of others who have the same problem :
也许太晚了,但是为了那些有同样问题的人:
public boolean isRunningOnEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT)
|| Build.PRODUCT.contains("vbox86p")
|| Build.DEVICE.contains("vbox86p")
|| Build.HARDWARE.contains("vbox86");
}
#4
-1
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或任何模拟器上总是“null”。确保在项目清单上添加了蓝牙权限。
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
#5
-2
I was also looking for a solution to this, I found this code snippet on some chinese blog when searching, I cant make out what its doing but maybe someone else can?
我也在找一个解决办法,我在一些中文博客上找到了这个代码片段,我不知道它在做什么,也许其他人可以?
public boolean isEmulator() {
String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
Log.d("ares","ANDROID_ID: "+android_id);
Log.d("ares","Build.PRODUCT: "+Build.PRODUCT);
boolean emulator = TextUtils.isEmpty(android_id) || "google_sdk".equals( Build.PRODUCT ) || "sdk".equals(Build.PRODUCT);
return emulator;
}
Please ignore if its totally no help...
如果完全没用,请忽略……
#1
2
You can check that the Bluestacks shared folder exist /sdcard/windows/BstSharedFolder
您可以检查Bluestacks共享文件夹是否存在/sdcard/windows/BstSharedFolder
Boolean onBlueStacks()
{
File sharedFolder = new File(Environment
.getExternalStorageDirectory().toString()
+ File.separatorChar
+ "windows"
+ File.separatorChar
+ "BstSharedFolder");
if (sharedFolder.exists())
{
return true;
}
return false;
}
#2
1
My version of BlueStacks is reporting my Build.Model
as GT-N7100
.
我版本的BlueStacks是报告我的构建。GT-N7100模型。
Using: android.opengl.GLES20.glGetString(android.opengl.GLES20.GL_RENDERER)
I get Bluestacks
.
使用:android.opengl gles20 . glgetstring (android.opengl gles20 . gles20 . gl_renderer)我获得了Bluestacks。
#3
0
It maybe too late but for the sake of others who have the same problem :
也许太晚了,但是为了那些有同样问题的人:
public boolean isRunningOnEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT)
|| Build.PRODUCT.contains("vbox86p")
|| Build.DEVICE.contains("vbox86p")
|| Build.HARDWARE.contains("vbox86");
}
#4
-1
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或任何模拟器上总是“null”。确保在项目清单上添加了蓝牙权限。
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
#5
-2
I was also looking for a solution to this, I found this code snippet on some chinese blog when searching, I cant make out what its doing but maybe someone else can?
我也在找一个解决办法,我在一些中文博客上找到了这个代码片段,我不知道它在做什么,也许其他人可以?
public boolean isEmulator() {
String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
Log.d("ares","ANDROID_ID: "+android_id);
Log.d("ares","Build.PRODUCT: "+Build.PRODUCT);
boolean emulator = TextUtils.isEmpty(android_id) || "google_sdk".equals( Build.PRODUCT ) || "sdk".equals(Build.PRODUCT);
return emulator;
}
Please ignore if its totally no help...
如果完全没用,请忽略……