BBC BASIC
Development >> Android >> Launching an app from a BASIC program
http://bbcbasic.conforums.com/index.cgi?board=android&action=display&num=1452950760

Launching an app from a BASIC program
Post by Richard Russell on Jan 16th, 2016, 12:26pm

The procedure listed below will launch an Android app from your BASIC program:

Code:
      DEF PROC_AndroidLaunchApp(app$)
      LOCAL env%, activity%, aclass%, mid%, manager%, mclass%, string%, purpose%
      SYS "SDL_AndroidGetJNIEnv" TO env%
      SYS "SDL_AndroidGetActivity" TO activity%
      SYS !(!env%+124), env%, activity% TO aclass% : REM GetObjectClass
      SYS !(!env%+132), env%, aclass%, "getPackageManager", \
      \                 "()Landroid/content/pm/PackageManager;" TO mid% : REM GetMethodID
      SYS !(!env%+136), env%, activity%, mid% TO manager% : REM CallObjectMethod
      SYS !(!env%+124), env%, manager% TO mclass% : REM GetObjectClass
      SYS !(!env%+132), env%, mclass%, "getLaunchIntentForPackage", \
      \                 "(Ljava/lang/String;)Landroid/content/Intent;" TO mid% : REM GetMethodID
      SYS !(!env%+668), env%, app$ TO string% : REM NewStringUTF8
      SYS !(!env%+136), env%, manager%, mid%, string% TO purpose% : REM CallObjectMethod
      SYS !(!env%+132), env%, aclass%, "startActivity", \
      \                 "(Landroid/content/Intent;)V" TO mid% : REM GetMethodID
      IF purpose% SYS !(!env%+136), env%, activity%, mid%, purpose% : REM CallObjectMethod
      SYS !(!env%+92),  env%, purpose%  : REM DeleteLocalRef
      SYS !(!env%+92),  env%, string%   : REM DeleteLocalRef
      SYS !(!env%+92),  env%, mclass%   : REM DeleteLocalRef
      SYS !(!env%+92),  env%, manager%  : REM DeleteLocalRef
      SYS !(!env%+92),  env%, aclass%   : REM DeleteLocalRef
      SYS !(!env%+92),  env%, activity% : REM DeleteLocalRef
      ENDPROC 

For example to launch the Chrome browser you could do:

Code:
      PROC_AndroidLaunchApp("com.android.chrome") 

The equivalent operation in Windows would take just a single API call (SYS "ShellExecute") but that's what progress brings!

Richard.