Android Code Snippet As I can know if the app this running in a phone or computer.

Erel

Administrator
Staff member
Licensed User
Based on: https://github.com/framgia/android-emulator-detector

Add to main:
B4X:
#AdditionalJar: detector.jar
#AdditionalJar: androidx.core:core
B4X:
Private Sub Button1_Click
    Wait For (IsEmulator) Complete (Emulator As Boolean)
    Log(Emulator)
End Sub


Public Sub IsEmulator As ResumableSub
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim jo As JavaObject
    jo = jo.InitializeStatic("com.framgia.android.emulator.EmulatorDetector").RunMethod("with", Array(ctxt))
    Dim callback As Object = jo.CreateEventFromUI("com.framgia.android.emulator.EmulatorDetector.OnEmulatorDetectorListener", "callback", Null)
    jo.RunMethod("detect", Array(callback))
    Wait For Callback_Event (MethodName As String, Args() As Object)
    Dim result As Boolean = Args(0)
    Return result
End Sub
 

Attachments

mcqueccu

Well-Known Member
Licensed User
Based on: https://github.com/framgia/android-emulator-detector

Add to main:
B4X:
#AdditionalJar: detector.jar
#AdditionalJar: androidx.core:core
B4X:
Private Sub Button1_Click
    Wait For (IsEmulator) Complete (Emulator As Boolean)
    Log(Emulator)
End Sub


Public Sub IsEmulator As ResumableSub
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim jo As JavaObject
    jo = jo.InitializeStatic("com.framgia.android.emulator.EmulatorDetector").RunMethod("with", Array(ctxt))
    Dim callback As Object = jo.CreateEventFromUI("com.framgia.android.emulator.EmulatorDetector.OnEmulatorDetectorListener", "callback", Null)
    jo.RunMethod("detect", Array(callback))
    Wait For Callback_Event (MethodName As String, Args() As Object)
    Dim result As Boolean = Args(0)
    Return result
End Sub

It gives false on modern emulators like NOX, MEMU and LDPlayer
 
Top