Share your advanced knowledge/code with the community.
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

How to create an Android application

by falsam Mon Mar 26, 2018 5:17 pm

Create an Android application.

Installing the JDK 1.8
Link http://www.oracle.com/technetwork/java/ ... 33151.html

Configuring the IDE: Specify the JDK installation folder.
IDE : Menu file ➽ Preference ➽ Compiler

Image

Configure the application.
Prepare your first code and save it.
Code: Select all
Enumeration
  #mf
  #mfFont
  #mfTime
EndEnumeration

Declare Start()
Declare ShowTime()

;No debug
CloseDebugOutput()

Start()

Procedure Start()
 
  LoadFont(#mfFont, "", 50)
 
  OpenWindow(#mf, 0, 0, 0, 0, "", #PB_Window_Background)
  TextGadget(#mfTime, 10, 100, 300, 50, "00:00:00")
  SetGadgetFont(#mfTime, FontID(#mfFont))
 
  AddWindowTimer(#mf, 0, 1000)
  BindEvent(#PB_Event_Timer, @ShowTime())
EndProcedure

Procedure ShowTime()
  Protected Time.s = FormatDate("%hh:%ii:%ss", Date())
  SetGadgetText(#mfTime, Time)
EndProcedure

It's time to set up your Android application.

Configuring the APK: An android application has the.apk extension
IDE : Menu Compiler ➽ Create App

Image

App Name : Name that will appear when installing the apk.

Version : Version of your application. To be incremented with each generation of the APK. Example : 1.0.0

Package id (lower case): Identifier of the Android application.
Package name : extensiondedomaine.nomdudomaine.android.nomduprojet

:idea: .android is optional.

You don't have to have a domain to publish an application. You can take for example your nickname on this forum.
Example : com.falsam.firstapplication

Outfile Filename : Application name for Android.

Ok button to save the configuration.
Create App button to create the Android application.

Image

With this example, I transferred the final apk to a tablet and smartphone manually via the usb cable.

Transfers of unknown applications.
Installing unknown applications (Internet, alternative store, USB transfer, etc...) requires changing phone settings to allow applications from unknown sources.

Mobile : Parameters ➽ General tab ➽ Security: Check Unknown sources.
Last edited by falsam on Mon Mar 26, 2018 5:42 pm, edited 1 time in total.

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: How to create an Android application

by falsam Mon Mar 26, 2018 5:22 pm

If you have successfully created your first application for Android (YeahhHHhhhh), I suggest you test this code to turn on or off your terminal's lamp.

viewtopic.php?f=9&t=1456

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
munfraid
 
Posts: 30
Joined: Sat Mar 24, 2018 1:33 pm

Re: How to create an Android application

by munfraid Tue Mar 27, 2018 6:16 pm

Thanks, falsam, for this sample and instruction - very helpful! I love all the things you share here and yet learned a lot from them.

Merci, falsam, pour cet exemple et cette instruction - très utile ! J'aime toutes les choses que vous partagez ici et pourtant j'ai beaucoup appris d'eux.
tj1010
 
Posts: 186
Joined: Wed May 27, 2015 1:36 pm

Re: How to create an Android application

by tj1010 Mon Apr 02, 2018 9:31 am

This tutorial already exists here, but IAP is the in app purchases key you get from your store panel, and package ID is a unique identifier on store and is used for nothing else; there is a bug with it and webview in older Android versions, but it's probably worked around by the SB team. There is a signing tool in the how-to-sign thread.
Peter53
 
Posts: 11
Joined: Thu Mar 28, 2019 2:58 pm

Re: How to create an Android application

by Peter53 Thu Mar 28, 2019 3:10 pm

Hi.
Sadly I can't get it to compile to Android.
At 60%, I get the 'app build failed' message.
I'm using SB 2.21, Windows 10.
Downloaded and installed Java jdk-8u202-windows-i586.exe from here:
https://www.oracle.com/technetwork/java ... 33151.html (Tried defferent versions).
I've set the JDK path to "C:\Program Files (x86)\Java\jdk1.8.0_202\"
Any help is truly appreciated.
Thanks
Dan23
 
Posts: 1
Joined: Fri May 24, 2019 1:43 pm

Re: How to create an Android application

by Dan23 Sat Jun 01, 2019 9:18 am

Hello,
I have the same problem: Invalid Version: broken! under the same conditions.
Whatever the program.
Where does this error come from?.
Spider Basic? of a bookstore?, yes but which one?
At 40%, I receive the message "app build build failed".
After each trial, I am forced to restart SpiderBasic.
I use SB 2.21 (x86, impossible to get 64 bits).Paid version
Windows 7 Pro Pack 1.
JDK path to "C: \ Program Files \ Java \ jdk1.8.0_211 \"
"Enable debugger" is enabled.
Everything seems correct. It's very frustrating.
Thank you
MetalOS
 
Posts: 5
Joined: Thu Oct 27, 2016 7:58 am

Re: How to create an Android application

by MetalOS Wed Jun 05, 2019 6:58 pm

Hi Falsam,

you will have an example of android application but with several windows. A simple trick to see how to manage multiple windows I'm looking for nothing more.

Thank you in advance.
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: How to create an Android application

by falsam Wed Jun 05, 2019 10:19 pm

Hi MetalOS

No real window in an apk (except for a tablet application).

Navigation between windows will be done through containers.

This little code doesn't record any data. It is a simple demonstration of navigation between two windows.
Code: Select all
Enumeration font
  #GlobalFont
  #TitleFont
EndEnumeration

Enumeration window
  #mf 
EndEnumeration

Enumeration gadget
  #mf0
  #mf1
 
  #mfTitle
  #mfTodoList
  #mfTodo
  #mfNewItem
  #mfAddItem
EndEnumeration

Global width, height

Declare Start()
Declare TodoList()
Declare TodoNew()
Declare TodoAdd()

Start()

Procedure Start()
  ; Really close the debug window
  CloseDebugOutput()
  !$('div').eq(0).remove()
 
  ; Font
  LoadFont(#GlobalFont, "Arial", 16)
  LoadFont(#TitleFont, "Arial", 20)   
  SetGadgetFont(#PB_Default, FontID(#GlobalFont))
 
  ; Background window
  OpenWindow(#mf, 0, 0, 0, 0, "", #PB_Window_Background) 
 
  width = WindowWidth(#mf)
  height= WindowHeight(#mf)
 
  ; Title
  TextGadget(#mfTitle, 5, 5, 200, 24, "Todo List")
  SetGadgetFont(#mfTitle, FontID(#TitleFont))
 
  ; First page
  If ContainerGadget(#mf0, 0, 30, width, height)
    ListViewGadget(#mfTodoList, 5, 0, width - 10, height - 100)
    ButtonGadget(#mfNewItem, 5, height - 70, width - 10, 24, "New item")
    CloseGadgetList()
  EndIf
 
  ; Second page
  If ContainerGadget(#mf1, 0, 30, width, height)
    StringGadget(#mfTodo, 5, 0, width - 10, 24, "")
    ButtonGadget(#mfAddItem, 5, height - 70, width - 10, 24, "Add item")   
    CloseGadgetList()
  EndIf 
 
  ;Trigger
  BindGadgetEvent(#mfNewItem, @TodoNew())
  BindGadgetEvent(#mfAddItem, @TodoAdd())
 
  TodoNew()
EndProcedure

Procedure TodoList() 
  HideGadget(#mf0, #False)
  HideGadget(#mf1, #True)
EndProcedure

Procedure TodoNew()
  HideGadget(#mf0, #True)
  HideGadget(#mf1, #False)
 
  SetGadgetText(#mfTodo, "Item " + Str(CountGadgetItems(#mfTodoList))) 
EndProcedure

Procedure TodoAdd()
  Protected buffer.s = GetGadgetText(#mfTodo)
 
  AddGadgetItem(#mfTodoList, -1, Buffer)
  TodoList()
EndProcedure
The listview is scrolled with the finger ^^

Enjoy

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
MetalOS
 
Posts: 5
Joined: Thu Oct 27, 2016 7:58 am

Re: How to create an Android application

by MetalOS Thu Jun 06, 2019 2:56 pm

Nickel, Merci Falsam.
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 2 guests