Android Question Detect debug or release at runtime

JordiCP

Expert
Licensed User
Longtime User
Can we detect at runtime if the app is either running in release, rapid or legacy debug mode?

I mean, without making use of conditional symbols in Build Configurations or other flags which have to be set by the user


--EDIT--

I was too fast asking, just found THIS. So the only remaining question how to detect if it is running in rapid or legacy debug mode
 

DonManfred

Expert
Licensed User
Longtime User
You dont need special build configurations.

#if debug as conditionalsymbol should do the trick.
or #if release
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Thanks both :)

About the second part of my question, in case it may interest someone, this seems to solve it (I don't know if may change in the future)

  • BA.debugMode==false --> release
  • BA.debugMode==true && BA.shellMode==false --> legacy debugger
  • BA.debugMode==true && BA.shellMode==true --> rapid debugger.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
About the second part of my question, in case it may interest someone, this seems to solve it (I don't know if may change in the future)
It will not change.

If you are pedantic then you should use BA.isShellModeRuntimeCheck(ba).
Otherwise your check will return the wrong result when called from a B4A compiled library (the compiled classes are always in release mode).
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Thanks.

So, to kill my problem (some hours ago I thought it was clear to me but now I am confused), please can you confirm these sentences?

If I call "ba.raiseEvent( this, .... )" from inside my lib in another thread, and I am using

1. release mode --> the B4A sub will be executed synchronously, using the same thread as the calling sub?
2. rapid debug mode --> if the caller is running in the UI thread and I have put @RaisesSynchronousEvents , the B4A sub will be executed synchronously?
3. rapid debug mode --> if the caller is running in its own non-UI thread, the B4A Sub will be executed asynchronously in the UI thread?
 
Upvote 0

umsid

Member
Licensed User
Longtime User
Hallo DonManfred,

hast Du ein Beispiel für Deinen Vorschlag?
You dont need special build configurations.

#if debug as conditionalsymbol should do the trick.
or #if release

ich möchte in Debug Fall meine Datenbank extern speichern, sonst intern:

B4X:
# if debug
    Dim DBFileDir As String : DBFileDir = File.DirDefaultExternal
# if release  
    Dim DBFileDir As String : DBFileDir = File.DirInternal

Das # if debug liefert gleich einen "Fehler beim Parsen des Attributs: #if debug"

Wie mache ich das?

vg
Guenter
 
Upvote 0
Top