javaandroidandroid-emulatoremulationbluestacks

Reliable way of detecting whether an Android app is running in 'BlueStacks'


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.

BlueStacks does not support multi-touch so I want to implement an alternative to the standard pinch-to-zoom functionality my current app has.

E.g.

If (appIsRunningInBlueStacks){
    mySurfaceView.enableMultiTouchAlternatives();
} else{
    mySurfaceView.enableMultiTouchFeatures();
}

What is a reliable way of ascertaining the value of appIsRunningInBlueStacks?

EDIT Summary of answers to comments on question:

Ben, Taras, thanks for the suggestions. The Build.MODEL etc. values for BlueStacks are:

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.

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

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!

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?


Solution

  • All the above methods are not working on BlueStacks 5. The correct way to do is checking if the path of /mnt/windows/BstSharedFolder exists. It is working fine on both BlueStacks 4 and 5.

       fun checkFilesExist(files: Array<String>): Boolean {
            files.forEach {
                val file = File(it)
                if (file.exists()) {
                    return true
                }
            }
            return false
        }
        
        fun isBlueStacks(): Boolean {
            val BLUE_STACKS_FILES = arrayOf(
                "/mnt/windows/BstSharedFolder"
            )
            return checkFilesExist(BLUE_STACKS_FILES)
        }