B4A: Rapid Android App Development using BASIC
()
About this ebook
Android is the world's favorite mobile operating system and B4A is the easiest rapid app development tool, allowing complete beginners to create powerful Android apps using the easily learned BASIC language.
This book covers B4A version 8.30. It starts with step-by-step beginners' guides explaining how to plan, design, develop, tes
Wyken Seagrave
Wyken Seagrave is a software engineer with many years' experience of using Visual Basic in multinational companies. He has taught Visual Basic for Applications at university level and written dozens of user manuals for a wide range of applications. He is also a professional author writing websites and books to explain science to a wider audience. He specializes in the history of the universe.
Related to B4A
Related ebooks
Xamarin Mobile Application Development for Android - Second Edition Rating: 0 out of 5 stars0 ratingsMEAN Web Development - Second Edition Rating: 0 out of 5 stars0 ratingsHow To Program A Mobile Game Rating: 4 out of 5 stars4/5Asynchronous Android Programming - Second Edition Rating: 0 out of 5 stars0 ratingsWebSphere Application Server 7.0 Administration Guide Rating: 0 out of 5 stars0 ratingsLearning Xamarin Studio Rating: 0 out of 5 stars0 ratingsLearning Xcode 8 Rating: 0 out of 5 stars0 ratingsiPad Application Development For Dummies Rating: 3 out of 5 stars3/5Mastering Android Game Development Rating: 0 out of 5 stars0 ratingsTCP/IP Sockets in Java: Practical Guide for Programmers Rating: 4 out of 5 stars4/5Programming with CodeIgniter MVC Rating: 0 out of 5 stars0 ratingsLibgdx Cross-platform Game Development Cookbook Rating: 0 out of 5 stars0 ratingsiOS 8 App Development Essentials Rating: 0 out of 5 stars0 ratingsLearning SQLite for iOS Rating: 0 out of 5 stars0 ratingsASP.Net Web Developer's Guide Rating: 0 out of 5 stars0 ratingsPrinciples of Programming: Java Level 1 Rating: 0 out of 5 stars0 ratingsBasic Guide to Programming Languages Python, JavaScript, and Ruby Rating: 0 out of 5 stars0 ratingsModern CSS: Master the Key Concepts of CSS for Modern Web Development Rating: 0 out of 5 stars0 ratingsVisual Studio Second Edition Rating: 0 out of 5 stars0 ratingsBeginning CSS: Cascading Style Sheets for Web Design Rating: 4 out of 5 stars4/5Drupal Multimedia Rating: 4 out of 5 stars4/5jQuery Game Development Essentials Rating: 0 out of 5 stars0 ratingsProfessional Visual Studio 2017 Rating: 0 out of 5 stars0 ratingsLiveCode Mobile Development: Beginner's Guide - Second Edition Rating: 4 out of 5 stars4/5HTML5 for Flash Developers Rating: 5 out of 5 stars5/5How to Cheat at IIS 7 Server Administration Rating: 0 out of 5 stars0 ratingsDebian: Try It; You'll Like It Rating: 0 out of 5 stars0 ratingsiOS 6 Application Development For Dummies Rating: 4 out of 5 stars4/5PHP Programming Solutions Rating: 0 out of 5 stars0 ratingsProgramming in GW-BASIC Rating: 4 out of 5 stars4/5
Programming For You
Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Unreal Engine from Zero to Proficiency (Foundations): Unreal Engine from Zero to Proficiency, #1 Rating: 0 out of 5 stars0 ratingsCoding All-in-One For Dummies Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsHTML in 30 Pages Rating: 5 out of 5 stars5/5C++ Learn in 24 Hours Rating: 0 out of 5 stars0 ratingsProfessional C++ Rating: 2 out of 5 stars2/5Web Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5
Reviews for B4A
0 ratings0 reviews
Book preview
B4A - Wyken Seagrave
Table of Contents
Table of Contents
Foreword by Erel Uziel
Preface
Introduction
Who this Book is For
For the Beginner
For the Professional
How this Book is Organized
Conventions Used in this Book
Code
Specifying Menus
Specifying Functional Arguments
Acronyms
Resources
Free Upgrades
Newsletter
We’d Like to Hear from You
About the Author
Acknowledgements
Part 1: Basics
1.1 Getting Started
Versions
Version of B4A
Version of Android
Two Versions
What You Need to Run B4A
Installing the Trial Version
Download B4A Trial
Install and Run the Trial
What you see
Your First App
Adding Your First Command
Debugging
Legacy vs Rapid Debugger
Breakpoints
Save the program
B4A-Bridge
Install the B4A-Bridge app on your device
Run B4A-Bridge on your device
Notes on Wireless Connection
B4A-Bridge Source Code
Connect the IDE to the device or Emulator
Changing Connection
Connect via [Tools > B4A-Bridge]
B4A-Bridge Status Bar
Remote Compilation Mode
B4A Designer
Stopping B4A-Bridge
Compiling your new app
Remote Compilation
Approve the app on your device
Breakpoint
Debug Window
Popup Variable Evaluation
Continuing the Run
Logging Events
Rotating the Device
More about Debugging
Your Second App: Using the Designer
The View and Layout Concepts
Running the Designer
Connect the Designer to your device.
Add a button
Configure your button
Generate Members
Adding Code for the Button
Add code to button
Load the Layout
Run your app
Your Third App
Stopping B4A-Bridge
More about Designer
1.2 The Integrated Development Environment
Icons
Icon Picker
Icon Picker Interface
Using Icon Picker in the Code Area
Using Icon Picker within the Visual Designer
File Menu
Edit Menu
Designer
Project Menu
Modules
Package Options
Compile Options
Tools Menu
IDE Options Sub-Menu
Debug Menu
Windows Menu
Help Menu
Toolbar
Module Tabs
Closing a Module
Popup Module Tab Menu
Code area
Subroutine Dropdown List
Zoom Control
Code Editor Splitter
Code
Revision Color Coding
Regions
Code header
Commenting and uncommenting code
Indentation
Autocomplete
Autocomplete event subroutines
Comments as Documentation
Block Completion
Context Menu
Highlighting occurrences of words
Structure Matching
URLs Clickable
Windows Area
Window Tabs
Libraries Manager
Files Manager
Modules Window
Logs Window
Find All References (F7)
Quick Search
The Warning Engine
Ignoring Warnings
The warnings
The IDE Meta File
1.3 Docking
Window Menus
Module Menu
Window Menu
Floating
Tab Groups
Horizontal Tab Group
Vertical Tab Group
Docking
Dragging Windows
Docking a Module
Docking Windows
Moving a Tab Group
Docking Windows
Auto Hide
Visual Designer
Restoring All Windows
1.4 Upgrade to Full Version
About Full Versions
B4A Standard Version
B4A Enterprise Version
B4A Site License
Academic Licenses
Purchase
Registering B4A
Java JDK and Android SDK Installation
Check if the Java JDK is already installed
Install the 32 bit Java JDK
Install the Android SDK and a platform
Install and configure B4A
Download and install B4A
Open B4A
License
Configure Paths
Javac.exe
Android.jar
Additional Libraries
Shared Modules Folder
Updating to a new version
Part 2: Creating Your App
2.1 The Project
Modules
Main Module
Starter Service
Attributes
Project Attributes
#AdditionalRes: Location, Package (optional)
#ApplicationLabel:
#BridgeLogger: True
#CanInstallToExternalStorage:
#CustomBuildAction: Step, Command, Arguments
#DebuggerDisableOptimizations: Value
#DebuggerForceFullDeployment:
#DebuggerForceStandardAssets:
#ExcludeClasses: Value List
#MultiDex: True
#SignKeyAlias:
#SignKeyFile:
#SignKeyPassword:
#SupportedOrientations: Value
#VersionCode: Value
#VersionName: Name
Library compilation attributes
Project Icon
Package name
Unique name
Allowed Characters
Google Play URL
Caution: Name cannot be changed
The Manifest
Manifest Editor
Escaping end of string characters
Manifest commands
minSdkVersion
android:targetSdkVersion
Conditional Manifest Commands
#Region and #End Region
Manifest editor macros
More information
2.2. Designing Your App
Fulfilling Wants and Needs
Android Versions
Popularity of Android Versions
The Android Screen
Status Bar
Navigation Bar
Notifications
App Design Step by Step
Basic Design Principles
Title Bar
Action Bar
Menu
Tabbed Views
Sliding Pages
Navigation Drawer
Animating your App
Advertising
Android Themes
More Advice
Managing Settings
Editing Settings
Saving and Retrieving Settings
Screens and Layouts
The Designer
Multiple activities
Returning from an Activity
Overlays
Menu Overlay
Layout as Overlay
How to Detect the Display Size
LayoutValues
Detecting Device Orientation
Allowed Screen Orientation
Adding views by code
Example
dips
DipToCurrent(Length as Int)
Percentage of Activity
Does the device have a keyboard?
App or Widget ?
Managing Permissions
Before Android 23
Runtime Permissions
2.3 Communicating with your User
Dialogs
Async Dialogs
Modal Dialogs
ToastMessageShow
Alarms
Notifications
ProgressDialog
ProgressBar
2.4 The Visual Designer
Layouts
Docking Windows
File Menu
New
Open
Save (Ctrl+S)
Save As
Remove Layout
AddView Menu
WYSIWYG Designer Menu
Connect (F2)
Disconnect (Shift+F2)
Tools Menu
Generate Members
Change grid
Send To UI Cloud (F6)
Windows Menu
Properties Window
Variants Window
Files Window
Script Windows
Views Tree
Reset
The Abstract Designer
Match Chosen Variant
View Controls
Context menus
Selecting views
Designer Scripts
Adding views in code
2.5 Designer Scripts Reference
Background
Designer Scripts and Activity Code
Running Scripts
Key Concepts
Pixel
Resolution
dpi : dots per inch
Screen Size
dip
Text Size
Standard Screen
Scale
Dock and Fill Strategy
Designer Scripting Basics
Selecting Variants
Script Language
Variables
%x and %y
Properties Within Scripts
Warning: Set Internal Properties before External
Text Properties
Other Properties
Methods
Other Keywords
Activity Methods
Activity.RerunDesignerScript (LayoutFile As String, Width As Int, Height As Int)
AutoScale: Layouts for Different Sized Devices
How AutoScale works
How to See the Effect of AutoScale
How to See the Effect of AutoScale on Text Size
How to Use AutoScale
AutoScaleRate(rate)
AutoScaleAll
AutoScale(View)
Different Layouts for Portrait and Landscape
Scaling strategy
Editing Views in a program
2.6 Compiling, Debugging & Testing
Compiling
Android Version
Build Configuration
Defining a Build Configuration
Build Configuration List
Conditional Compilation
Compilation Modes
Debug Mode
Release Mode
Release (obfuscated)
Conditional Compilation
Command Line Compiler
Running from Batch Files
Debugging
#ExcludeFromDebugger Attribute
Restart (F11)
Rapid debugging
Limitations of the Rapid Debugger
How the Rapid Debugger Works
Editing Code using the Rapid Debugger
Legacy Debugging
Breakpoints
Breakpoint Limitations
Debugger Control
Debug Window
Call Stack
Variables List
Watches
Hovering
Logging
Logging with B4A-Bridge in Release Mode
Compiling for Material Design
Holo Theme
Material Themes in WYSIWYG Designer
Testing your App
Connecting the Debugger to a Device or Emulator
Debugging Communication Channels
Opening the Channel
B4A-Bridge
USB Debugging
Connecting the Device via USB
Android Debug Bridge
Debugging with USB
The Emulator or Android Virtual Device (AVD) Manager
Introduction
How B4A interacts with Emulated Devices
Using the Android Virtual Device Manager
Missing Tabs
Android Virtual Devices (AVDs)
Creating an AVD
AVD Name (Required)
Device (Required)
Target (Required)
CPU / ABI (Required)
Keyboard
Skin (Required)
Front / Back Camera
Memory Options
Internal Storage
SD Card
Emulation Options
Creating a Device Definition
Running a Virtual Device and scaling for Real Size Emulation
No Scaling
Scale display to real size
Interacting with your Virtual Device
PC Keyboard Shortcuts
Mac Keyboard Shortcuts
Exchanging files with the PC
Troubleshoot Connection Problems
2.7 Graphics and Drawing
Drawing Methods
Setting Backgrounds of Views and the Activity
View Drawables
Bitmaps
Drawables
Background Property
ColorDrawable
GradientDrawable
BitmapDrawable
Example Code
StateListDrawable
NinePatchDrawable
Canvas Object
Initializing a Canvas
Drawing onto a Canvas
Importing a Bitmap file into Canvas
Copying a Drawable onto a Canvas
Making the Canvas Draw Itself
Restricting the Drawing Area
Most common Canvas functions
DrawBitmap (Bitmap1 As Bitmap, SrcRect As Rect, DestRect As Rect)
DrawBitmapRotated (Bitmap1 As Bitmap, SrcRect As Rect, DestRect As Rect, Degrees As Float)
DrawCircle (x As Float, y As Float, Radius As Float, Color As Int, Filled As Boolean, StrokeWidth As Float)
DrawColor (Color As Int)
DrawLine (x1 As Float, y1 As Float, x2 As Float, y2 As Float, Color As Int, StrokeWidth As Float)
DrawRect (Rect1 As Rect, Color As Int, Filled As Boolean, StrokeWidth As Float)
DrawRectRotated (Rect1 As Rect, Color As Int, Filled As Boolean, StrokeWidth As Float, Degrees As Float)
DrawText (Text As String, x As Float, y As Float, Typeface1 As Typeface, TextSize As Float, Color As Int, Align1 As Align)
DrawTextRotated (Text As String, x As Float, y As Float, Typeface1 As Typeface, TextSize As Float, Color As Int, Align1 As Align, Degree As Float)
Example Program
More Complex Examples
Animating Bitmaps
Diagrams / Charts
Charts Framework
Out of Memory Errors
2.8 Databases
Storing Data
Database fundamentals
Database
Table
Record
Field
Primary Key
Field Type
Relational Data
Database Files
KeyValueStore2 Library
Encrypting Databases
Showing Tables to the User
Database Administration
DBMS Tools
SQLiteBrowser
SQLiteSpy
DBMS Apps
SQL Object
Declare SQL Object
Initialize SQL Object
DBUtils
DBUtils Fundamentals
Preliminary SQL Steps
DBUtils Field Types
DBUtils Functions
Sample DBUtils Program
SQLite
SQL
SQLite
More Information on SQLite
Sample SQLite Program
Manifest Typing
SQLiteExceptions
SQL Library
SQLite Commands
Database Creation
Table creation
Dropping a Table
Adding records
Updating records
Retrieving data
Deleting data
Rename a table
Add a field
Using SQLite to Convert Ticks to Strings
Implementing a Database Relationship
2.9 Modules
Process
When Does Android Kill a Process?
Creating or Adding Modules
Shared Modules
Module Attributes
#AdditionalJar
#ExcludeFromLibrary
Visibility and Lifetime of Variables and Subs
Summary
Public Variables
Private Variables
Variables within Other Subs
Visibility of Subroutines
Activity Global Variables
Class_Globals
Local variables in Subs
Documenting Modules
Documenting a Class
Documenting a Service, Activity or Code Module
Sub Process_Globals
Modules Containing Process_Globals
Process_Globals Variables
Initialization of Process_Globals
Lifetimes of Process_Globals Variables
Process_Globals in Starter Service
Restriction of Process_Globals Variables
Rotating Device
How to Access Process_Globals Variables
Activity Module
The Activity Concept
Activity Module
Activity Attributes
Variables within an Activity
Activity Life Cycle
Activity Events
Sub Activity_Create (FirstTime As Boolean)
Sub Activity_Resume
Sub Activity_Pause (UserClosed As Boolean)
StartActivity (Activity As Object)
Activity.Finish vs ExitApplication
Creating a Menu
Activities vs Windows Forms
Multiple Activity Modules
Class module
What is a Class?
Benefits of Classes
Example
Sub Class_Globals
Public vs Private Variables
Public vs Private Subs
Classes vs Types
Classes vs Code Modules
Adding a class module
Class structures
Polymorphism
Self reference
Classes and Activity Object
Activities that Extend Classes
Limitations of Classes
Code module
Service Module
Why use a Service
How the user interacts with a Service
Alternative to an Activity
Starter Service
Android’s View of Services
How to Start a Service
Starting a Service While App is in Background
When Services End
Wake Lock
Service Code
Service Attributes
SubRoutines
When to Use a Service
Notifications
Accessing other modules
Sample Projects Using Services
2.10 Publishing and Monetizing Your App
User Help
Branding and Marketing
Setting Your Project Parameters
Package Name
Project Attributes
Setting Icons
Google Play Store Icon
Launcher Icon
[Project > Choose Icon]
Action Bar Icons
Creating Icons
Sources of Icons
Implementing MipMap
Notification Icon Recommendations
Icon Sizes
Installing Icons
Generating Your APK
APK File
Keys and Certificates
Signing
Debugging Certificates
Signing for Distribution
Creating or Loading a Private Key
The KeyStore
Compiling the APK
SHA1 Certificate Fingerprint
Monetizing Your App
Ways of Monetizing Your App
Libraries Supporting Advertising
AdMob
AdBuddiz
AdiQuity
TapForTap
AppLovin
Selling Your App
In-App Billing
Licensing
Registering as a Google Play Developer
How to Register as a Google Play Developer
Merchant Account
Prepare Your App’s Google Play Page
User Support
Google Play Developer Console
Upload your App to Google Play
Distributing Apps elsewhere
Preparing the User’s Device
Amazon Appstore
By Email
Downloading from a website
Other App Publishers
2.11 Getting More Help
Anywhere Software
Forum
Chat Room
Video Tutorials
On-Line Tutorials
Linked In
On-line Documentation
PDF Guides
Library Browsers
B4a Object Browser
B4AHelp
Part 3: Language and Core Objects
3.1 B4A’s Language
BASIC
B4A
Lexical Rules
Statement Separator
Comments
Splitting Long Lines
Variables
Constants
Types
Primitive Types
Hex Literals
Non-Primitive Types
Core Types
Reference to Non-Primitives
Type Conversion
Rank
Creating Your Own Types
Objects
Initialization of Objects
Declaring Variables
Dim Statement
No Option Explicit
Editor Warnings of Undeclared Variables
Allocating Values
Type Checking
Use of Unassigned Variables
Pass by Value
Pass by Reference
Naming of Variables
Hungarian Notation
Arrays
Dimensions
Declaring an Array
Default Type
Cannot Change Dimensions
Saving and Retrieving Data
Filling an array using the Array keyword
Length of an Array
Arrays of Objects
Array Dimensions are Fixed
Lists
Maps
Type variables
Declaring Types
Recursive Types
Casting
Visibility of Variables
Expressions and Operators
Mathematical expressions
Relational Operators
Logical Operators
Regular Expressions
Conditional statements
If – Then
If-Then-End If
If-Then-Else-End If
Select – Case
Loop structures
For – Next
For-Each
Do-While
Do-Until
Exit a Loop
Differences between B4A and Visual Basic
Subs
Declaring a Sub
Naming
Calling a Sub
Parameters
Returned value
Creating Tooltips for Subs
Resumable Subs
Can be paused
Contains either Sleep or Wait For
Resumable Sub is Paused
ResumableSub Type
Sleep
Wait For
Events
Core Object Events
Reacting to an Event
Example
Shared Event Handler
View Events
Commonest View Events
Error Handling
Runtime Errors
Exceptions
Uncaught Runtime Exceptions
Try-Catch
When to use a Try-Catch
String manipulation
Mutable Strings
The String functions
Number formatting
Keywords
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Abs (Number As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ACos (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ACosD (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Array
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Asc (Char As Char) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ASin (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ASinD (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ATan (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ATan2 (Y As Double, X As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ATan2D (Y As Double, X As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ATanD (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png BytesToString (Data() As Byte, StartOffset As Int, Length As Int, CharSet As String) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSub (Component As Object, Sub As String) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSub2 (Component As Object, Sub As String, Argument As Object) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSub3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSubDelayed (Component As Object, Sub As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSubDelayed2 (Component As Object, Sub As String, Argument As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CallSubDelayed3 (Component As Object, Sub As String, Argument1 As Object, Argument2 As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CancelScheduledService (Service As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Catch
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png cE As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Ceil (Number As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CharsToString (Chars() As Char, StartOffset As Int, Length As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Chr (UnicodeValue As Int) As Char
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ConfigureHomeWidget (LayoutFile As String, EventName As String, UpdateIntervalMinutes As Int, WidgetName As String) As RemoteViews
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Continue
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Cos (Radians As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CosD (Degrees As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png cPI As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png CreateMap() As Map
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png CRLF As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png Density As Float
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Dim
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png DipToCurrent (Length As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png DoEvents
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Exit
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ExitApplication
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png False As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png File As File
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Floor (Number As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png For
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png For Each
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png GetDeviceLayoutValues As LayoutValues
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png GetType (object As Object) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png If
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png InputList (Items As List, Title As String, CheckedItem As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png InputListAsync (Items As List, Title As CharSequence, CheckedItem As Int, Cancelable As Boolean) As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png InputMap (Items As Map, Title As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png InputMapAsync (Items As Map, Title As CharSequence, Cancelable As Boolean) As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png InputMultiList (Items As List, Title As String) As List
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Is
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png IsBackgroundTaskRunning (ContainerObject As Object, TaskId As Int) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png IsDevTool (ToolName As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png IsNumber (Text As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png IsPaused (Component As Object) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LastException As Exception
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LoadBitmap (Dir As String, FileName As String) As Bitmap
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LoadBitmapResize (Dir As String, FileName As String, Width As Int, Height As Int, KeepAspectRatio As Boolean) As Bitmap
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LoadBitmapSample (Dir As String, FileName As String, MaxWidth As Int, MaxHeight As Int) As Bitmap
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Log (Message As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Logarithm (Number As Double, Base As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LogColor (Message As String, Color As int) As void
Max (Number1 As Double, Number2 As Double) As Double
Me As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Min (Number1 As Double, Number2 As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Msgbox (Message As CharSequence, Title As CharSequence)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Msgbox2 (Message As CharSequence, Title As CharSequence, Positive As String, Cancel As String, Negative As String, Icon As Bitmap) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png MsgboxAsync (Message As CharSequence, Title As CharSequence, Positive As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Msgbox2Async (Message As CharSequence, Title As CharSequence, Positive As String, Cancel As String, Negative As String, Icon As Bitmap, Cancelable As Boolean) As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Not (Value As Boolean) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png Null As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png NumberFormat (Number As Double, MinimumIntegers As Int, MaximumFractions As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png NumberFormat2 (Number As Double, MinimumIntegers As Int, MaximumFractions As Int, MinimumFractions As Int, GroupingUsed As Boolean) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png PerXToCurrent (Percentage As Float) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png PerYToCurrent (Percentage As Float) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Power (Base As Double, Exponent As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ProgressDialogHide
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ProgressDialogShow (Text As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ProgressDialogShow2 (Text As String, Cancelable As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png QUOTE As String
Regex As Regex
Regex Options
Regex Methods
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Return [value]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Rnd (Min As Int, Max As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png RndSeed (Seed As Long)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Round (Number As Double) As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Round2 (Number As Double, DecimalPlaces As Int) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Select
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Sender As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Sin (Radians As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SinD (Degrees As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Sleep (Milliseconds As int) As void
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Sqrt (Value As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png StartActivity (Activity As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png StartService (Service As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png StartServiceAt (Service As Object, Time As Long, DuringSleep As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png StartServiceAtExact (Service As Object, Time As Long, DuringSleep As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png StopService (Service As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Sub
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SubExists (Object As Object, Sub As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png TAB As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Tan (Radians As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png TanD (Degrees As Double) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png ToastMessageShow (Message As String, LongDuration As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png True As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Try
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Type
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Until
Wait For [(Sender)]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png While
3.2 VB6 versus B4A
Controls vs. Views
Dim
ReDim
Boolean Operations
Not
Using Integers as Boolean
Global Const
Repeating Structures
For…Next
Loops, If-Then, Select Case
Exit
ElseIf/EndIf
Colors
Subroutines
Declaring a Sub
Calling a sub
Functions
Exit Sub
DoEvents
Format
InputBox
Loop
MsgBox
Random Numbers
Rnd
RndSeed
Randomize
Round
Val()
SetFocus
Divide by Zero
Shell
Timer
TabIndex
Setting Label Transparency
Constants
String Members
Left$ and Right$
Len
Replace
Case
Trim
Instr
Error Trapping
VB6
B4A
Immediate Window
vs. Logs
Tab
3.3 Core Objects
List of Core Objects
General
Constants
Drawing Objects
File Objects
Views
Activity
Views within an Activity
Activity Events
ActionBarHomeClick
Click
KeyPress and KeyUp Events
LongClick
PermissionResult (Permission As String, Result As Boolean)
Touch (Action As Int, X As Float, Y As Float)
Activity Members
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png ACTION_DOWN As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png ACTION_MOVE As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\11.png ACTION_UP As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png AddMenuItem (Title As String, EventName As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png AddMenuItem2 (Title As String, EventName As String, Bitmap1 As Bitmap)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png AddMenuItem3 (Title As String, EventName As String, Bitmap1 As Bitmap, AddToActionBar As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png AddView (View1 As View, Left As Int, Top As Int, Width As Int, Height As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Background As Drawable
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png CloseMenu
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Color As Int [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png DisableAccessibility (Disable As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Finish
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png GetAllViewsRecursive As IterableList
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png GetStartingIntent As Intent
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png GetView (Index As Int) As View
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Height As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Initialize (EventName As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Invalidate
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Invalidate2 (Rect1 As Rect)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png Invalidate3 (Left As Int, Top As Int, Right As Int, Bottom As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Left As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png LoadLayout (Layout As String) As LayoutValues
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png NumberOfViews As Int [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png OpenMenu
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png RemoveAllViews
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png RemoveViewAt (Index As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png RequestFocus As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png RerunDesignerScript (Layout As String, Width As Int, Height As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SendToBack
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SetActivityResult (Result As Int, Data As Intent)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SetBackgroundImage (Bitmap1 As Bitmap) As BitmapDrawable
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png SetLayout (Left As Int, Top As Int, Width As Int, Height As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Tag As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Title As CharSequence
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png TitleColor As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Top As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\19.png Width As Int
Application
Application Members
Icon As Bitmap
LabelName As String
PackageName As String
VersionCode As Int
VersionName As String
Bit
Bitwise Operations
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png And (N1 As Int, N2 As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ArrayCopy ( SrcArray As Object, SrcOffset As Int, DestArray As Object, DestOffset As Int, Count As Int ) As Void
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png InputStreamToBytes (In As Inputstream) As Byte()
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Not (N As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Or (N1 As Int, N2 As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ParseInt (Value As String, Radix As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ShiftLeft (N As Int, Shift As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ShiftRight (N As Int, Shift As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToBinaryString (N As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToHexString (N As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToOctalString (N As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png UnsignedShiftRight (N As Int, Shift As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Xor (N1 As Int, N2 As Int) As Int
Constants
Colors
DialogResponse
Gravity
KeyCodes
Typeface
CSBuilder
CharSequence
Styling with CSBuilder
PopAll is highly recommended
Chaining CSBuilder Methods
Using a CSBuilder Object
Members
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Alignment ( Alignment As android.text.Layout.Alignment ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Append ( Text As java.lang.CharSequence ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png BackgroundColor ( Color As int ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Bold As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Clickable ( EventName As String, Tag As Object ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Color ( Color As int ) As anywheresoftware.b4a.objects.CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png EnableClickEvents ( Label As android.widget.TextView ) As void
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Image ( Bitmap As Bitmap, Width As Int, Height As Int, Baseline As Boolean ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Length As Int [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Pop As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png PopAll As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png RelativeSize ( Proportion As float ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ScaleX ( Proportion As float ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Size ( Size As int ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Strikethrough As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToString As java.lang.String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Typeface ( Typeface As android.graphics.Typeface ) As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Underline As CSBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png VerticalAlign ( Shift As int ) As CSBuilder
DateTime
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Add (Ticks As Long, Years As Int, Months As Int, Days As Int) As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Date (Ticks As Long) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png DateFormat As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png DateParse (Date As String) As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png DateTimeParse (Date As String, Time As String) As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png DeviceDefaultDateFormat As String [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png DeviceDefaultTimeFormat As String [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetDayOfMonth (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetDayOfWeek (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetDayOfYear (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetHour (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetMinute (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetMonth (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetSecond (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetTimeZoneOffsetAt (Date As Long) As Double
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetYear (Ticks As Long) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ListenToExternalTimeChanges
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Now As Long [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetTimeZone (OffsetHours As Double)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png TicksPerDay As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png TicksPerHour As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png TicksPerMinute As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png TicksPerSecond As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Time (Ticks As Long) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png TimeFormat As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png TimeParse (Time As String) As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png TimeZoneOffset As Double [read only]
Drawing Objects
Bitmap
BitmapDrawable
Canvas
ColorDrawable
GradientDrawable
Path
Rect
StateListDrawable
Exception
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Message As String [read only]
File Object
Filenames
Adding Files to your Project
Folder locations on Device
Text encoding
File
InputStream
OutputStream
TextReader
TextWriter
Intent
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Action As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_APPWIDGET_UPDATE As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_CALL As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_EDIT As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_MAIN As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_PICK As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_SEND As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png ACTION_VIEW As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png AddCategory (Category As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ExtrasToString As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Flags As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetData As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetExtra (Key As String) As Object
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png HasExtra (Key As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize (Action As String, URI As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize2 (URI As String, Flags As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png PutExtra (Name As String, Value As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetComponent (Component As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetType (Type As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png WrapAsIntentChooser (Title As String)
LayoutValues
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png ApproximateScreenSize As Double [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png Height As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png Scale As Float
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png toString As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\11.png Width As Int
List
How to use a List
Members:
Map
How to use a Map
Members:
MediaPlayer
Event: Complete
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Duration As Int [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize2 (EventName As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialzied As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsPlaying As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Load (Dir As String, FileName As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Looping As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Pause
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Play
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Position As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Release
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetVolume (Right As Float, Left As Float)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Stop
Notification
Permissions:
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png AutoCancel As Boolean [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Cancel (Id As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Icon As String [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize2 (ImportanceLevel As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Insistent As Boolean [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Light As Boolean [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Notify (Id As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Number As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png OnGoingEvent As Boolean [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetInfo (Title As String, Body As String, Activity As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetInfo2 (Title As String, Body As String, Tag As String, Activity As Object)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Sound As Boolean [write only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Vibrate As Boolean [write only]
Regex
Regex As Regex
More about Regex
Options
Regex Members:
CASE_INSENSITIVE
IsMatch (Pattern As String, Text As String) As Boolean
IsMatch2 (Pattern As String, Options As Int, Text As String) As Boolean
Matcher (Pattern As String, Text As String) As Matcher
Matcher2 (Pattern As String, Options As Int, Text As String) As Matcher
MULTILINE
Replace (Pattern As String, Text As String, Template As String) As String()
Replace2 (Pattern As String, Options As Int, Text As String, Template As String) As String()
Split (Pattern As String, Text As String) As String()
Split2
Matcher Object
RemoteViews
Events:
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png HandleWidgetEvents (StartingIntent As Intent) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetImage (ImageViewName As String, Image As Bitmap)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetProgress (ProgressBarName As String, Progress As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetText (ViewName As String, Text As String)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetTextColor (ViewName As String, Color As Int)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetTextSize (ViewName As String, Size As Float)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SetVisible (ViewName As String, Visible As Boolean)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Images\15.png UpdateWidget
Service
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png StartForeground (Id As Int, Notification1 As Notification)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png StopForeground (Id As Int)
String
Immutable Strings
Mutable Strings
Number formatting
Smart Strings
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png CharAt (Index As Int) As Char
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png CompareTo (Other As String) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Contains (SearchFor As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png EndsWith (Suffix As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png EqualsIgnoreCase (other As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png GetBytes (Charset As String) As Byte()
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IndexOf (SearchFor As String) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IndexOf2 (SearchFor As String, Index As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png LastIndexOf (SearchFor As String) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png LastIndexOf2 (SearchFor As String, Index As Int) As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Length As Int
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Replace (Target As String, Replacement As String) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png StartsWith (Prefix As String) As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SubString (BeginIndex As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png SubString2 (BeginIndex As Int, EndIndex As Int) As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToLowerCase As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToUpperCase As String
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Trim As String
StringBuilder
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Append (Text As String) As StringBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Insert (Offset As Int, Text As String) As StringBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Length As Int [read only]
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Remove (StartOffset As Int, EndOffset As Int) As StringBuilder
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png ToString As String
Timer
Event: Tick
Example:
Members:
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Enabled As Boolean
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png Initialize (EventName As String, Interval As Long)
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\19.png Interval As Long
G:\SkyDrive\PennySystems\Android\Basic4Android\Book\Libraries\Images\15.png IsInitialized As Boolean
Views
AutoCompleteEditText
Button
CheckBox
CustomView
EditText
HorizontalScrollView
ImageView
Label
ListView
Panel
ProgressBar
RadioButton
ScrollView
SeekBar
Spinner
TabHost
ToggleButton
View
WebView
3.4 Inline Code
Returning Data to B4A
Part 4: Libraries
4.1 Libraries
Introduction
What is a library?
Types of Libraries
Core Library
Standard Libraries
Additional Official Libraries
Additional User Libraries
Additional libraries folder
Telling the IDE where to find additional libraries
Error message Are you missing a library reference?
Updates to Internal Libraries
Referencing Libraries
Warning on Unused Libraries
Using Libraries
Updating Additional Libraries
Using Inline Code to access Libraries
Creating Libraries
Benefits of creating Libraries
Preparing Your Library
Main Activity Excluded
Library specific attributes
Project attributes
Module Attributes
Classes Attributes
How to Compile a Library
Output
No Home Screen Widget Libraries
How to publish your library
4.2 Standard Libraries included with Full Version
Introduction
List of Standard Libraries
Accessibility Library
List of types:
Accessiblity
Administrator Library
On-line Link
AdminManager
Animation Library
Animation
Audio Library
List of types:
AudioRecordApp
AudioStreamer
Beeper
JetPlayer
MediaPlayerStream
SoundPool
VideoRecordApp
VideoView
B4XEncryption Library
B4XCipher
BitmapCreator Library
List of types:
ARGBColor
BitmapCreator
DrawTask
PremultipliedColor
CallSubUtils (Legacy) Library
CallSubUtils
RunDelayedData
Camera Library
CameraEx Class
List of types:
Camera
Camera2 Library
Camera2
CameraSize
ContentResolver Library
List of types:
ContentResolver
ContentValues
Uri
DateUtils Library
DateUtils
Period
Daydream Library
Daydream
FirebaseAdMob Library
List of types:
AdView
InterstitialAd
NativeExpressAd
RewardedVideoAd
FirebaseAnalytics Library
FirebaseAnalytics
FirebaseAuth Library
FirebaseAuth
FirebaseUser
FirebaseNotifications Library
FirebaseMessaging
RemoteMessage
FirebaseStorage Library
FirebaseStorage
StorageMetadata
GameView Library
Tutorial
List of types:
BitmapData
GameView
GPS Library
List of types:
GPS
GPSSatellite
Location
HTTP (Legacy) Library
List of types:
HttpClient
HttpRequest
HttpResponse
HttpUtils2 (Legacy) Library
HttpJob
IME Library
Example
IME
JavaObject Library
JavaObject
JSON Library
About JSON
JSONGenerator
JSONParser
KeyValueStore2 Library
KeyValueStore
LiveWallpaper Library
LWEngine
LWManager
Network Library
List of types:
ServerSocket
Socket
UDPPacket
UDPSocket
NFC Library
About NFC
NdefRecord
NFC
TagTechnology
OkHttp Library
List of types:
OkHttpClient
OkHttpRequest
OkHttpResponse
OkHttpUtils2 Library
HttpJob
HttpUtils2Service
MultipartFileData
Phone Library
CallItem
CallLog
Contact
Contacts [Legacy Object]
Contacts2
ContentChooser
LogCat
PackageManager
Phone
PhoneAccelerometer [Legacy object]
PhoneCalls
PhoneEvents
PhoneId
PhoneIntents
PhoneOrientation [Legacy Object]
PhoneSensors
PhoneSms
PhoneVibrate
PhoneWakeState
RingtoneManager
Sms
SmsInterceptor
SmsMessages
VoiceRecognition
PreferenceActivity Library
PreferenceActivity Limitations
List of types:
PreferenceCategory
PreferenceManager
PreferenceScreen
RandomAccessFile Library
AsyncStreams
B4XSerializator
CompressedStreams
CountingInputStream
CountingOutputStream
RandomAccessFile
Reflection Library
Notes
Reflector
RuntimePermissions Library
RuntimePermissions
Serial Library
List of types:
BluetoothAdmin
Serial
Sip Library
List of types:
Sip
SipAudioCall
SQL Library
List of types:
Cursor
ResultSet
SQL
StringUtils Library
StringUtils
TTS Library
TTS
USB Library
List of types:
MtpDevice
UsbAccessory
UsbDevice
UsbDeviceConnection
UsbEndpoint
UsbInterface
UsbManager
UsbRequest
ViewsEx Library
FloatLabeledEditText
RatingBar
Switch
xCustomListView Library
CLVItem
CustomListView
XmlSax Library
XML
Sax
Attributes
SaxParser
XUI Library
List of types:
B4XBitmap
B4XCanvas
B4XFont
B4XPath
B4XRect
B4XView
XUI
4.3 Additional Libraries and Modules
Introduction
Finding Additional Libraries
Additional libraries folder
Telling the IDE where to find additional libraries
Additional Official Libraries and Classes
Adiquity
AdMob
AnotherDatePicker class
AsyncStreamsText
Analytics
Audio
Bluetooth Low Energy
Camera
CameraEx
DBUtils
DropBox Sync
Excel
Facebook User Authentication
Firebase RemoteConfig
GamePad
Google Maps v2
Google Play Services
HttpServer
JSch
JTidy
Licensing
NB6
Net
NotificationListener Library
OAuth
PayPal
SearchView
SMB
Speak Button
SQLCipher
StateManager
StdActionBar Library
TableView
Tap for Tap
USB Host
USBSerial
XMLBuilder
YouTube
Additional User Libraries
Introduction
To obtain or update a user library
Which ones does a project need?
How to use a library
List of libraries
Additional User Libraries
Downloading User Libraries
Custom class templates
How to create a library
How to Share your Library
License
Dialogs Library
Source
Notes
ColorDialog
ColorDialogHSV
ColorPickerDialog
CustomDialog
CustomDialog2
DateDialog
FileDialog
InputDialog
NumberDialog
TimeDialog
TabHostExtras Library
getTabContentViewPadding (tabHost1 As TabHost) As RectWrapper
getTabEnabled (tabHost1 As TabHost, index As Int) As Boolean
getTabHeight (tabHost1 As TabHost) As Int
getTabHostPadding (tabHost1 As TabHost) As RectWrapper
getTabTextSize (tabHost1 As TabHost) As Float
getTabVisibility (tabHost1 As TabHost, index As Int) As Boolean
setTabContentViewPadding (tabHost1 As TabHost, left As Int, top As Int, right As Int, bottom As Int)
setTabEnabled (tabHost1 As TabHost, enabled As Boolean)
setTabEnabled2 (tabHost1 As TabHost, enabled As Boolean, index As Int)
setTabGradientDrawable (tabHost1 As TabHost, orientation As String, color1 As Int, color2 As Int, cornerRadius As Float)
setTabGradientDrawable2 (tabHost1 As TabHost, orientation As String, color1 As Int, color2 As Int, cornerRadius As Float())
setTabHeight (tabHost1 As TabHost, tabHeight As Int)
setTabHostPadding (tabHost1 As TabHost, left As Int, top As Int, right As Int, bottom As Int)
setTabTextColor (tabHost1 As TabHost, Color As Int)
setTabTextColorStateList (tabHost1 As TabHost, ColorStateListName As String)
setTabTextSize (tabHost1 As TabHost, TextSize As Float)
setTabTitle (tabHost1 As TabHost, Title As String, TabIndex As Int)
setTabVisibility (tabHost1 As TabHost, visible As Boolean)
setTabVisibility2 (tabHost1 As TabHost, visible As Boolean, index As Int)
Toggle Library
Part 5: External Tools and Services
5.1 Firebase Services
What is Firebase?
Integrating Firebase Services into B4A
More about Google APIs for Android
Supported Firebase Services in B4A
FirebaseAnalytics: Analytics & crash reports
Notifications / Push messages
AdMob Advertisements
Authentication with Facebook or Google Accounts
Firebase RemoteConfig
More Information
Google API Project
Adding Firebase Snippets
5.2 Maven Repositories
Apache Maven Project
Maven Repositories
Maven artifacts
Android SDK and maven repositories
Tools
Benefits
5.3 AAR Library Support
Introduction
Adding Reference to AAR
Including AAR libraries in B4A Apps
Example 1
Example 2
Index
Foreword by Erel Uziel
I started developing Basic4ppc, a development tool for Pocket PC devices (later renamed to Windows Mobile) in 2005. It was a real challenge for me to build a new programming language and development environment. Five years later, when Microsoft decided to stop developing Windows Mobile in favor of a different platform, and with the first signs of the new Android operating system, I decided that it was time to change direction and B4A was born. I had a rare opportunity to go back to the drawing board and then, with the many lessons learnt from the previous project, build a powerful and simple development tool for native Android applications.
Since its first release, B4A has improved dramatically. Today, B4A supports 99% of the advanced features of Android. Features such as NFC, Wifi-Direct, serial ports, graphics and many more are supported, and all of the features are designed to be simple to use yet powerful enough to meet your real-world requirements.
B4A is used by companies, organizations, educational institutes and individuals from all over the world. I honestly believe that B4A is the best development tool for native Android applications available today. B4A together with B4i and B4J allows developers to easily build native cross platform solutions.
Over the years, a very active on-line community has evolved around B4A. This community is the heart of B4A. In our forums there are hundreds of thousands of messages with questions, answers, examples, bugs, tutorials, classes and libraries. The ecosystem around B4A is huge.
Many customers have asked for a full, comprehensive book to help them with their own development. I was thrilled to hear that Wyken has taken on himself the challenging task of mapping this ecosystem. I’m happy to say that Wyken, an experienced software developer and author, has done a great job.
I’m sure that this book will help you to quickly get started with development of your own Android apps.
I’m looking forward to see you becoming part of our community!
Erel Uziel
CEO, Anywhere Software
Preface
Introduction
This book describes the features of and how to develop Android apps using B4A Version 8.30.
B4A is widely recognized as the simplest and most powerful Rapid App Development tool available for Android. It is used by tens of thousands of enthusiastic developers. A complete list of its features and benefits can be found here.
Who this Book is For
This book serves two audiences:
For the Beginner
For those new to B4A, new to BASIC, or even new to programming, this book contains step-by-step tutorials for the complete beginner. It explains everything you need to know to use this exciting and easy application development environment design to create and sell your app on Android devices in the shortest possible time without having to climb the steep learning curve of learning Java.
For the Professional
For experienced B4A developers, this book brings together a huge range of reference material never previously assembled in one place and organizes it into an easily accessible form.
It contains all the key terms used by the core language and its official libraries. It includes examples to show how the code is used and links to further on-line information.
How this Book is Organized
Part 1 – Basics
We begin with a tutorial which walks you gently through the process of installing the free Trial Version of B4A, connecting it to your device, then writing, running, designing and debugging your very first Android app.
We explain every feature of the Integrated Development Environment and show you how to upgrade to the Full Version of B4A. This will give you access to the Libraries discussed in Part 4.
Part 2 – Creating Your App
Here we go in detail through the process of creating a real app, including the principles of design, how your app can communicate with the user, how you can use Designer Scripts or Anchors to automatically modify the layout of your app to suit different devices, and how to compile, debug and test your app using either real or virtual devices.
We discuss creating graphics and databases. We examine how processes, services and activities live and die in Android. We look at the various types of modules you can create, examine ways you can make money from your app and finally explore ways you can get more help in using B4A.
Part 3 – Language and Core Objects
Parts 3 and 4 form the reference sections of this book.
Part 3 includes two chapters of reference material which cover every part of B4A’s language and core objects (that is, objects accessible from every app).
We also compare B4A’s language with Microsoft’s Visual Basic.
Part 4 – Libraries
In this reference section we discuss libraries (only available if you have upgraded to the Full Version of B4A), and explain how to create your own libraries and share them with others (should you wish to).
We give full details of the Standard Libraries included in the Full Version installation. We also discuss some of the many Additional Libraries and Modules, including all the Official
ones created by Anywhere Software, which you can download from the B4A website.
Conventions Used in this Book
Code
Examples of B4A code are shown indented, like this:
Sub Activity_Create(FirstTime As Boolean)
Msgbox(Welcome to B4A!
, )
End Sub
Code within other text is usually shown with this font: Sub Activity_Create. However, this is not always possible, since the electronic versions of this book include many links (to make it easy to find related parts of the book), which overlap code and have a different font.
We also use the same font to highlight options in on-screen dialog boxes.
Specifying Menus
In this book we specify B4A menus by surrounding them by [square brackets] and separating the parts by the > symbol. For example the following would be shown as [Edit > Copy]:
Specifying Functional Arguments
When we specify the types of the arguments which are used to call functions, we adopt a different convention than that used in the B4A on-line documentation. On-line they include the full path to the argument types, for example:
DrawBitmap (Bitmap1 As android.graphics.Bitmap, SrcRect As android.graphics.Rect, DestRect As android.graphics.Rect)
We find this difficult to read, so in this book we simply write:
DrawBitmap (Bitmap1 As Bitmap, SrcRect As Rect, DestRect As Rect)
The reason that the full paths are specified on-line is that B4A types, such as Bitmap, are actually wrappers
for the full Java class. This allows for greater flexibility in extending the B4A language in the future. But in most cases you do not need to worry about this when developing your apps.
Acronyms
We use the following acronyms in this book:
ADB Android Debug Bridge
AES-256 Advanced Encryption Standard
ANSI American National Standards Institute
API Application Program Interface
APK Filename extension for Android Package
.APK Android Package (filename extension)
ARGB Alpha,Red,Green,Blue (Color Specification)
ASCII American Standard Code for Information Interchange
AVD Android Virtual Device
BA A B4A object which library developers can use to raise events and to get access to the user activity, application context and other resources.
.BAS Filename extension for BASic files
BASIC Beginner’s All-Purpose Symbolic Instruction Code
BOM Byte Order Mark
C2DM Cloud To Device Messaging
CPU Central Processing Unit
CSV Comma-Separated Values
DBMS DataBase Management System
dip density independent pixel
DOS Disk Operating System
dp density independent pixel (same as dip)
dpi dots per inch
dps density independent pixels (same as dip)
DSA Digital Signature Algorithm
DTMF Dual-tone multi-frequency
EAS Embedded Audio Synthesizer
.EXE Filename extension for an EXEcutable file
FTP File Transfer Protocol
GMT Greenwich Mean Time
GPS Global Positioning System
GPU Graphics Processing Unit
HD High Definition
HDPI High-density Dots Per Inch
HSV Hue, Saturation and Value (Color Specification)
HTML HyperText Markup Language
HTTP HyperText Transfer Protocol
IDE Integrated Development Environment
IME Input Method Editor
IP Internet Protocol (as in IP address
)
.JAR File extension for Java ARchive
JDK Java Development Kit
JET The SONiVOX interactive music engine.
JSON JavaScript Object Notation
LDPI Low-density Dots Per Inch
MAC Media Access Control address of a device
MDPI Medium-density Dots Per Inch
MIDI Musical Instrument Digital Interface
MIME Multi-Purpose Internet Mail Extensions
NDEF NFC Data Exchange Format
NFC Near-Field Communication
NMEA National Marine Electronics Association
OEM Original Equipment Manufacturer
OS Operating System
PC Personal Computer
.PNG Filename extension for a Portable Network Graphic
POP3 Post Office Protocol 3
PPC Pocket Personal Computer
PRN Pseudo-Random Number
px pixels
RAM Random Access Memory
RFCOMM Radio Frequency COMMunication
RGB Red,Green,Blue (Color Specification)
SAX Simple API for XML
SD Secure Digital
SDK Software Development Kit
SFTP SSH File Transfer Protocol or Secured File Transfer Protocol
SIM Subscriber Identity Module
SIP Session Initiation Protocol
SKU Stock Keeping Unit
SMS Short Message Service
SQL Structured Query Language
SSH Secure Shell Protocol
SSL Secure Sockets Layer
TCP/IP Transmission Control Protocol/Internet Protocol
TTS Text to Speech
TTS Text-To-Speech
UDP User Datagram Protocol
UI User Interface: the images, sounds, keyboards and other objects which allow the user to communicate with the device.
URI Uniform Resource Identifier
URL Uniform Resource Locator
USB Universal Serial Bus
UTC Coordinated Universal Time (equivalent to Greenwich Mean Time).
UTF-16 16-bit Universal Character Set Transformation Format
UTF-8 8-bit Universal Character Set Transformation Format
UUID Universal Unique Identifier
VB6 Visual Basic 6.0
VM Virtual Memory
VOIP Voice Over Internet Protocol
WYSIWYG What You See Is What You Get
XHDPI Extra-High-density Dots Per Inch
XLS Microsoft Excel Spreadsheet (File Extension)
XML eXtensible Markup Language
Resources
Resources to support this book can be found here.
The main source of support is the active community of enthusiastic developers around the world who already use B4A and are very happy to support others who have problems.
See the Getting More Help Chapter for details.
Free Upgrades
Customers who purchase an electronic version of this book from the Penny Press store are entitled to free upgrades when we introduce new editions to match changes in B4A. Sadly we cannot provide free upgrades to the paperback version. The upgrade website is here.
Newsletter
To receive notices about these upgrades to the electronic version and other news about this book, please subscribe to the newsletter.
We’d Like to Hear from You
We hope you will enjoy this book and find it useful. Despite our best efforts, there may still be errors in this book. The publisher would be grateful if readers would send reports of them, together with any suggestions for improvements to future editions, to
b4a@pennypress.co.uk
Thank you.
We would also be very grateful if you would take the time to rate it on the main Amazon website: USA Amazon site
About the Author
Wyken Seagrave is a professional developer of applications and websites using Visual Basic, Visual Basic for Applications, PHP and MySQL, among other languages. He has taught computer programming at college and university, and written many user manuals for the applications he has developed.
His great passion in life is to bring knowledge of the history of the universe to a wider public. To this end he has written books and websites dealing with the subject both as fact and fiction, including the History of the Universe website (also available as an eBook on Amazon) and the Time Crystal series.
Acknowledgements
Thanks to Erel Uziel and Anywhere Software for creating and supporting B4A, to Klaus Christl for his excellent documentation, to Bob Paehr for proof-reading the entire first edition, to Bob and Kevin and making valuable suggestions, to Dave, Paul Holthuizen, Kevin and Peter Sobol for pointing out a number of typos, to Javier Parraga for working on the Spanish translation, to Johann Stock for raising a number of issues as well as working on translating the book into German, to Vladimir Shirkina for translating it into Russian and to the entire B4A user community for creating libraries and many other invaluable assets.
Wyken Seagrave
Part 1: Basics
We begin with a tutorial which walks you gently through the process of installing the free Trial Version of B4A, connecting it to your device, then writing, running, designing and debugging your very first Android app.
We explain every feature of the Integrated Development Environment.
Then we show you how to upgrade to the Full Version of B4A. This will give you access to the Libraries discussed in Part 4.
1.1 Getting Started
Note: B4A runs on PCs with Windows 2000 and above, including Windows 8. Both 32-bit and 64-bit systems are supported.
Versions
Version of B4A
This book covers the functionality of B4A Version 8.30.
Version of Android
The above version of B4A supports most features of all versions of Android up to and including 8.1 Oreo. It also supports the file structures of the latest version of the Android SDK.
Two Versions
There are two versions of B4A: the Trial Version and the Full Version. The main differences are in brief:
Price: the trial version is FREE! The price of the full version depends upon which flavor you purchase.
Remote Compilation Mode: this feature, which makes compiling your apps simple and painless, only runs under the free trial. This means that if you are running the free version, you do not need to install the Java JDK and Android SDK packages (which are both required for local compilation), although you may if you wish. The full version only supports local compilation. This has the advantage of enabling features such as using an emulator, USB debugging and others. Note that B4A includes a Rapid Debugger which can greatly shorten development times. You can use this feature with both the trial and full versions, but in both cases it requires that you install the Java JDK, even when you use Remote Compilation with the trial version.
Project Size: this is limited for the free version.
Duration: the free version only works for 30 days. The full version works indefinitely, although the time during which you receive free upgrades depends upon which licence you have purchased.
Advanced features: the full version supports libraries and other advanced features missing from the trial.
What You Need to Run B4A
You will need a PC running Windows with at least 512 Mb of RAM.
You can test your app on either an emulator (a virtual device running on your PC) or a real device. We recommend you have a real device available as it usually takes less time to install your app there than on an emulator and apps running there usually execute faster.
If you use a real device it should be running Android 1.6 or above (that is Android 2.x, 3.x etc.).
Installing the Trial Version
In the tutorials, we assume you will be using the free trial version of B4A. We also assume you will not want to install the Java JDK to begin with, so we will postpone explanation of the Rapid Debugger until Chapter 2.
Download B4A Trial
Download the latest version of the B4A Trial version from here.
Install and Run the Trial
Installing .NET Framework
B4A requires .Net Framework 4.5.2 on Windows Vista, or .Net Framework 4.0. on Windows XP. If the required Framework is not present on your machine, you will be prompted to download and install it.
After you run the Trial, you will see a welcome screen. Click Close
What you see
B4A presents you with a window consisting of several areas:
This is where you create, test and compile your apps. To begin, you will be editing code in the Code Area. We deal with all the other areas in more detail below, in the Integrated Development Environment (IDE) section.
Note that normally apps are developed within projects and projects are stored in folders.
Your First App
When you create a new B4A app, a sample project is already loaded into the Code Area, allowing you to create a simple app with very little additional code.
The sample project consists of two pieces of code or Modules: an Activity module called Main and a Service module called Starter. These are indicated by two Module Tabs near the top of the IDE:
We will discuss the Starter service later, and in these tutorials we can ignore it and concentrate upon the Main activity.
All types of B4A code is divided into blocks called Regions. A Region is an area of your code which you can rapidly expand or collapse, and by default the first two regions are collapsed:
You can expand a Region by clicking the + sign.
Adding Your First Command
You are now going to add a line of code to your app to make it do something simple.
Scroll down to the section which begins
Sub Activity_Create(FirstTime As Boolean)
and type in the line
Msgbox(Welcome to B4A!
, )
The code you see should now be similar to the following. If your default code is different, you can either edit your code to be the same, copy the following or download Your First App
from this book’s resource page and unzip it to a new folder within your projects folder.
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Msgbox(Welcome to B4A!
, )
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
This is just about the minimum code required to create an app.
Debugging
Debugging is the process of removing errors (bugs) in your code. We are going to use this simple app to learn a little about how to debug in B4A.
Legacy vs Rapid Debugger
To learn about how to debug an app, we are going to look at setting breakpoints and logging events. Note that B4A has an amazing feature called the Rapid Debugger, but to use it with Remote Compilation, you would need to install the Java JDK. For the purposes of keeping things simple during this introduction, we will use the legacy debugger, and introduce the Rapid Debugger later.
To use legacy debugging, you must first enable it using
[Tools > IDE Options > Use Legacy Debugger]
Breakpoints
An important way of debugging is to set a point where execution of your app will pause, so that you can examine the values of variables.
Note also that the default project has a single breakpoint already added:
We deal with breakpoints in more detail later. For now you can add or remove breakpoints by clicking the red dot, but you will need this breakpoint if you want to follow this tutorial
Save the program
Before you can run the app, first you must save the code into a project folder.
We recommend you create a single folder to hold all your B4A projects, and within this folder, create separate folders, one for each project. When you create a new program, B4A will create sub-folders called Files and Objects in the selected folder. For this reason you must put every program in a separate sub-folder of your projects folder.
Use the [File > Save] menu option to save the program, or type Ctrl+S.
B4A-Bridge
Before you can run the program, you need to connect B4A to a device or an emulator. There are several options (see Testing Options), but as a first step we recommend using B4A-Bridge to connect to your device. B4A-Bridge is a free app which runs on an Android mobile phone or tablet. It was built using B4A! The source code is available here. It is advised to connect the device to a charger while running B4A-Bridge.
B4A-Bridge is made of two components. One component runs on the device and allows the second component (which is part of the IDE) to connect and communicate with the device. The connection is done over the local wireless network. (See the note below about Bluetooth.)
Once connected, B4A-Bridge supports all of the IDE features which include: installing applications, viewing the logs, debugging and the visual designer (taking screenshots is not supported).
Android doesn’t allow applications to quietly install other applications. Therefore, when you run your application using B4A-Bridge, you will see a dialog asking you to approve the installation.
Install the B4A-Bridge app on your device
B4A-Bridge is available free in Google Play and Amazon Market. Search for: B4A Bridge. Install the app on your device (Android mobile phone or tablet).
Note: When a new version of B4A is released it is worth checking whether a new version of B4A-Bridge also exists.
Run B4A-Bridge on your device
It will display a screen similar to:
Notes on Wireless Connection
B4A connects via WiFi. In order to connect, your development machine and your mobile device must both be connected to the same hub.
In some cases, the IP address displayed on B4A-Bridge may be the mobile network address. In that case you can find the local wireless address in the wireless advanced settings page.
B4A-Bridge Source Code
The source code is available here.
Connect the IDE to the device or Emulator
Changing Connection
Your IDE can be connected to several devices and/or emulators at the same time. If you have already connected to one of them and wish to change and connect to another, you must run [Tools > Clean Project] before running the compiler. You will then be asked which device or emulator you wish to run the app on.
Connect via [Tools > B4A-Bridge]
Go back to the B4A IDE running on your PC and select the menu option [Tools > B4A-Bridge > Connect]. You should see a list of all devices running B4A-Bridge, with an indication if they have not been started.
You can quickly connect to the last IP address using F2. Alternatively you could enter the IP address as shown in B4A-Bridge on the device.
B4A-Bridge Status Bar
Or you can click the B4A-Bridge: status bar at the bottom of the IDE screen to re-connect to the most recent device or disconnect from it. Its wording will change from : Disconnected to : Trying to connect and then to : Connected or back again to Disconnected.
Remote Compilation Mode
When using the B4A trial version, checking the Remote Compilation Mode option will allow remote compilation without installing any further software.
B4A Designer
When B4A-Bridge gets connected, it first checks if another App, B4A Designer, needs to be updated. B4A Designer allows you to design your app directly on your device. If B4A Designer has not been installed, B4A-Bridge will ask whether to install it. You might see a screen something like this:
Select Verify and install, so Google can check the app for viruses. You will then see the following:
Click on Install. The app will be installed and you will see a confirmation page telling you so.
At this point, you do not need to open the designer, but you can do so as it will be useful soon.
Stopping B4A-Bridge
B4A-Bridge keeps running as a service until you press on the Stop button. You can always reach it by pulling down the notifications screen from the notification bar at the top of the device’s screen.