BBC BASIC
« Launching an app from a BASIC program »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:58pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

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


member is offline

Avatar




Homepage PM


Posts: 803
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 »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls