BBC BASIC
« Launching an app from a BASIC program »

Welcome Guest. Please Login or Register.
Jan 23rd, 2018, 7:13pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Launching an app from a BASIC program  (Read 408 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 692
xx Launching an app from a BASIC program
« Thread started 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls