Android Code Snippet detect emulator/VM

getRadioVersion() always returns empty on VM,
and returns version number on real android device.
B4X:
Sub Process_Globals
    Private Native As JavaObject
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then Native.InitializeContext

    Dim IsVM As Boolean = Native.RunMethod("IsVM", Null)
    If IsVM Then
        MsgboxAsync("You are using Virtual Environment","IsVM ?")
    Else
        MsgboxAsync("You are using Real Environment","IsVM ?")
    End If
    
End Sub

#If JAVA
public Boolean IsVM()
{
    return android.os.Build.getRadioVersion().trim().length() == 0;
}
#End If
Not sure, why this happens, but I know it just works. ?
I don't have official explanation for this.

Code: github.com/Back-X/anti-vm/blob/main/android/anti-vm.b4a
Release: github.com/Back-X/anti-vm/releases/download/1/anti-vm.apk
 

AbdurRahman

Member
2. It will return false for tablets without radio.
Nice pick ! Just Tablets or Mobile as well ?


I read code. Its nice but is signature based.
and will fails to detect if list doesn't matched.

I was hoping to find an universal way to detect every emulator, even after 20 years.

In windows, I just check no. of ports. And vm return 0.
I think it may be possible in android too.
From my short lifespan, I see Every android mobile, always has charging port, radio plug and other ports.

I may be wrong as well.
Thanks a lot Sir for precious time.
 
Top