B4A vs challenge 2, and what was the final result after about 1.5 days???

Peter Simpson

Licensed User
Please don't laugh at Erel
You should watch some English comedy sketches, I was joking, being sarcastic, and every body knows it especially Erel. Erel is making some great game examples that looks great and that runs smoothly at 60FPS, that's all I was saying. Anyway I really shouldn't have to explain myself to you so I'm off to watch the football on the box now.

Hmm tut tut tut...


Well-Known Member
Licensed User
You should watch some English comedy sketches, I was joking, being sarcastic, and every body knows it especially Erel. Erel is making some great game examples that looks great and that runs smoothly at 60FPS, that's all I was saying. Anyway I really shouldn't have to explain myself to you so I'm off to watch the football on the box now.

Hmm tut tut tut...
Ya, everybody includes me. I know you were joking. Sorry for disturbing. Enjoy your football. We all are happy using B4X.


Licensed User
Hello all,
I'm not sure if anybody remembers this, but about 3 years I was issued a challenge by one of my friends who is an Android app developer for a company, he challenged me to create an app against him and the loser would have to pay for snooker or a curry when we went out next, suffice to say that I won that particular challenge by about 50 minutes, I even had time to walk to get some shopping before he finished his app using Eclipse.

The dreaded rematch:
Yes, 3 years later my friends brought up his horrible defeat and offered me a rematch but this time he would be using Android Studio as the firm he works for uses Android Studio as their default development tool now. I decided to accept his challenge but I will admit that as it was Android Studio I presumed that he would have a huge advantage, so I set some ground rules.
  1. We can't copy and paste previously used code from our projects, except for connecting to my online MySQL databases.
  2. We can only use online resources, we CAN'T rely on our previous code base.
  3. it's a 1 day challenge, but because we set the bar so high the challenge went into a 2nd day.
  4. In theory the app MUST be able to be placed into the Play Store if we just swapped from MySQL to SQLite.
  5. The app MUST have it's own camera feature.
  6. The app MUST have at least one search feature for searching the database for results.
  7. The app has to look presentable.
  8. The app should only be designed for use with Android phones, thus the app has to work with all of my phones in my desk drawer, Android tablets don't really matter.
  9. The SDK must be set to 26.
We had 3 options for making an app. Option one was to create a 10" tablet bespoke entertainment system like what his company makes for their clients, this was my app of choice but Imran pointed out that we needed lots of video feeds with mapping and other features, plus in theory we could not really put that on the Play Store. Option two was a simple restaurant system for taking orders and matching order to table numbers with extra food options and images, that was my second choice. Imran had a spare database on his laptop but after looking at it we decided that app would take a good few days to write, Imran writes those apps in his spare time and I wanted to beat him at his own game. We went for option three, a simple stock control app. Imran has used my template MySQL databases before so I setup 2 spare databases on my online server to speed things up and that was the challenge.

Imran turned up on Saturday morning with a work colleague and asked me if his colleague/friend could also join in on the challenge. Wait a minute I said, so that's two professional developers using Android Studio vs me on my Jack Jones using B4A. At first I said no way, but then Imran kept saying that I just keep boasting how simple B4A is to use (Erel, I personally blame you for that one ;)). Imran broke me down and I reluctantly said yes to his challenge, but if I win he owes me not one but 2 nights out for curries or pizzas or snooker, he said yes okay :).

Let the challenge begin, option 3 was right up my street: #takingcandyfromababy.
We started coding at midday and I had to remind both Imran and his colleague Matthew that there was absolutely no conferring aloud just idle chit chat jokes etc etc etc. Imran could help Matt get to grips with the third database that I setup for him as Imran knows that particular database like the back of his hand.

After an hour I had setup my database connectivity and a few other key features like the manifest colors for the app itself, ToolStrip resources, permissions etc, basically I had figured out what I personally thought was the best layout for my app, don't forget that we could only use online resources and not our own previously used code base, that would make the challenge way too easy.

Deep down I personally already know that I had a HUGE advantage over Imran and Matt, I had this forum and ALL of its great resources at my disposal which is basically all I needed. Imran and Matt on the other hand had the whole internet to wade through with lots and lots and lots of code and results just to complete simple things tasks blah blah blah, I know which one I preferred ;)

As we laughed and joked together whilst coding, deep down none of us wanted to lose, no way, especially Imran again. All I could hear was Imrans keyboard tapping away like crazy, he types about twice as fast as I do. I was coding away, Imran was coding away, Matt was coding away too. I was drinking rum and codes, Imran was drinking tea, orange juice and ribenna, I let Matt just raid my alcohol drinks cupboard at will, hopefully the alcohol would slow him down a bit as he was typing really quickly too. It was now 5pm, We went 3 ways on pizzas, garlic bread and fries, oh yes and 2 large bottles of coke. Wow, doesn't time fly when you are having fun, well I was having fun as all the code I needed I was finding extremely easily on b4x.com, I was not sure about the other two though. At about 6pm I suggested that we stopped and continue the following day, both Imran and Matt said they would preferred to carry on for a few hours more, so I agreed. At 7:30pm I said that we had to stop now as I was going out for a few drinks with a couple of friends, so we stopped.

Pause time rules:
I suggested that we set some rules
  1. NO coding
  2. Definitely NO coding
  3. Absolutely NO coding
  4. No looking up solution or answers
  5. No home work whatsoever which is basically the same as 4
We all agreed to the above terms, we would continue the following day at my house again at midday.

The following day, Sunday:
So Imran and Matt turned up at mine at 10:30am, about 90 minutes early, but my house and my rules, laptops can only be turned on after 11:45am :rolleyes:

Midday arrives and we start coding again, I'm on a roll and I can hear Imran saying how happy he is with his progress. At this point I was shocked as I was sure that they were both behind me the day before and that their apps would not as nice as mine should be. The pressure was now on so I pushed and pushed and pushed and pushed, I typed faster and faster and faster, I typed as fast as possible debugging my code as I tested it. My code is looking messy in places, not my usual neat and tidy code, but I really didn't care, at this point code that should have been 10 lines long but was in fact 15+ lines long didn't bother me as long as it worked. I usually do some coding and once I get the routines working, I then go back through the routine or sub making it smaller, faster and neater if possible, but not this weekend, not on Saturday or Sunday, my code could look like it had been dragged through bushes backwards and I wouldn't care one little bit, I didn't have time for that rubbish, as long as it worked that is all I cared about, I could always tidy up the code at a later date.

At about 3:20pm I came up with a great idea, I would add a Bluetooth barcode scanner. I quickly looked on the forum and I found Erels updated BluetoothManager 2018 example. Hmm, hmm, hmm I was not happy, I had never seen this updated 2018 module before and I just couldn't get it to read from any barcode scanners, BluetoothManager 2018 would always find and connect to all of my scanners first time of asking, but when it came to scanning/reading/sending the data to my app, Private Sub AStream_Error was the only sub that was firing, it should have been the Private Sub AStream_NewData (Buffer() As Byte) sub firing. I sat there for well over 45 minutes maybe even over an hour trying to figure out how to get the module to receive data from any of my Bluetooth barcode scanners. I never had this problem with the previously posted code, I remembered adding the previous code and scanning/reading barcodes instantly getting results.

I was now getting seriously frustrated, I was getting annoyed, I sent Joanne my better half a message, she just replied with 'don't worry about it. You will find a way to get it working, you always do', but I couldn't, I was now getting more and more annoyed with the whole situation and this new updated BluetoothManager 2018 module. The fact that no matter what I tried doing, BluetoothManager 2018 was not firing the Newdata sub, just the error sub was just sending me crazy :mad:

I needed a break, I could hear Imran getting frustrated about something so I asked him what was the matter. He replied that he couldn't find code that he needs on the net which he has used lots of times in the past and it was on his laptop. That was my chance to do a Trump and to cut a good deal with Imran and Matt. The deal was that he could use the code from one of his previous projects as long as I could do the same, but only once and for one feature, we shook hands and within 10 minutes or so I had implemented some code from a previous project of mine and the barcode scanners were all working perfect in my Android app, now that was my get out of jail free card played in Monopoly. To tell you the truth I had heard Imran moaning for about 90 minutes, but I only asked him when I could see he was seriously getting annoyed and I needed a quick 10 minute break.

The home straight, it was game over, but who for?:
Well, have you ever seen that old western called 'The good, the bad and the ugly', well that was us three but we were not 3 gun slingers standing about in a circle with guns, we were 3 developers sitting down with laptops firing (typing) away like crazy, by the way I'm 'The good' in this movie :p

The time was about 6:15pm and I had gotten everything I wanted to integrated into my app. I had integrated more into my app than I really needed too, but hey, I could so I did. I didn't announce that I had finished, but instead I sent Imran an email link to Dropbox and in turn he sent it to Matt, they installed my app trying it out for themselves. Matt said 'hey what, you've finished it already', I said yes, Matt instantly replied 'well it can't be that good if you have finished it that quickly, you must be missing loads of features', I said to check it out for yourself, so he did. Imran on the other hand just looked at me in complete disbelief and said 'not again, seriously'. As it was, I found out later that both Imran and Matt were nowhere near finishing their apps, they said that they probably needed an extra 3 or 4+ hours to go, but I had finished my app and I had more features too, both of them just couldn't believe it. Whilst they were testing my app and playing about with it, I went though my code tidying it up slightly, nothing special and that was aloud as it didn't change the outcome of the B4A vs challenge 2. If it wasn't for me having issues with both the Camera 2 and BluetoothManager 2018 modules, I would easily have finished 2 hours earlier.

Things didn't all go 100% to plan though.
  1. I couldn't get BluetoothManager 2018 update to work as I expected, that was the only thing that really annoyed me.
  2. I made a spelling a mistake whilst adding long click event to xCLV, I don't use normal short clicks.
  3. My auto centre and auto sizing the ImageViews source code took longer than expected, my faults completely.
  4. Took too long for me to find the FontAwesomeToBitmap sub on the forum even though I know it was here somewhere.
  5. I wrote a working ProperCase routine when there are some on the forum already like ToProperCase, wasting precious time.
  6. The Camera 2 module does not work with my older Samsung phones (legacy errors), so I reverted back to the original Camera module that works perfect, about 60 minutes wasted there with the Camera 2 module.
  7. I spent too long testing image compression, way too long.
  8. I could speed up high quality photo image taking, but images were not high enough quality, so currently the images are larger than I like but I'm sure with more time I can make them 1/5 smaller in size with minimal image quality loss.
  9. Numberpad module would open by itself if tabbing from left to right, I just removed the extra tab to fix that issue.
  10. I wished that I had added a login screen, it would only added an extra 15 or so minutes to the project.
  11. I don't like the view stock and add stock icons, but they will do for now.
  12. If I knew that I had all that extra time in hand, I would have added a small mobile Bluetooth printer to my app.

Here is a video of the winning app, sorry MY winning app developed in a day and a half using B4A :D

The audio is not the best and my voice/throat was not right and I have a cold too so the sound is muffled in places, so sorry about that.

The app took a day and a half to develop mainly because I added more features than what was actually needed, and I changed my mind on a number of occasions about the look and feel of the app, plus I had the issues listed above.

Thanks to all the library creator/wrappers, without whom this challenge would not have been remotely possible for me to do.

Will Imran challenge me again one day, third time lucky, hopefully not ;)

This is so cool, I wonder if we could start our own challenges within this forum, I know everybody is probably so busy with their own projects but wouldn't it be awesome if we could start some sort of competition/challenge between us, maybe @Erel can agree to this and somehow give the winner some type of incentive, we can raise funds for the price ourselves. Before I read this post this morning i was dreading to get back on my laptop and finish a project i started a few weeks ago for one of my clients, The reason i was so hesitant to get back to this project was because this is an App someone else did for Android, i'am now porting it to B4i, it's a very neat app for what it does but unfortunately the code is very messy besides it was done years ago with an older version of B4A so there's a lot of unneeded code, so you could imagine going through thousands of line of code that don't have any comments and don't make very much sense :D.
My point is after reading this post I realized what i had forgotten, and that is how easy it is to develop with this beautiful platform that @Erel has created for us, if i was doing this type of job in any other than B4A, B4i or B4J i would have probably ended up crazy already LOL, most importantly is the amount of resources you can find in the forums if you know how to search for it, After reading the post i was so pumped up that i immediately got back on my laptop and continued working on this project, just a few minutes before i decided to reply to this thread, in under 2 hours i was able to get a lot done on this project that i was being hesitant to continue, i am now feeling accomplished for the day and very pumped up to finish this project soon.

So, Thanks for this post i'm sure i'm not the only who was inspired by it.

Keep it up.


Licensed User
why not organize a Xui2D game coding challenge? Then there will be (hopefully) a lot of games as reference for Erel's site to attract more people to B4X.
(I'm still waiting for a decent categorized showcase page there aswell ;) )


Staff member
Licensed User
why not organize a Xui2D game coding challenge? Then there will be (hopefully) a lot of games as reference for Erel's site to attract more people to B4X.
(I'm still waiting for a decent categorized showcase page there aswell ;) )
We are not there yet... XUI2D stable version wasn't even released.

Peter Simpson

Licensed User
Your friend yet still not convinced to use B4X? I guess he will buy you more than 3 dinner treats or snooker if he uses B4X and found how powerful it is.
Imran has always been impressed with the business apps that I create for clients using both B4A, he also likes my personal B4J apps too @aeric. Matt on the other hand says that I should leave the rebellion forces and try joining the dark side, if you know what that refers too ;)

Enjoy your football.
My team lost 3-1 grrr :mad:

Such a cool story :)
Thank you @thedesolatesoul, that means a lot coming from you, you know the score :)

My point is after reading this post I realized what i had forgotten, and that is how easy it is to develop with this beautiful platform that @Erel has created for us, .............

After reading the post i was so pumped up that i immediately got back on my laptop and continued working on this project, just a few minutes before i decided to reply to this thread, in under 2 hours i was able to get a lot done on this project that i was being hesitant to continue, i am now feeling accomplished for the day and very pumped up to finish this project soon.

So, Thanks for this post i'm sure i'm not the only who was inspired by it.

Keep it up.
Wow thank you for the compliments @walterf25, but it was the whole community that inspired me to take on the 2nd challenge in the first place.

I will admit one thing though, half way through the challenge I though to myself that I must be absolute crazy taking on these two, it's not going to end well for me, it's going to cost me not one but two nights out with Imran and he will not make it cheap for me, I wouldn't for him and he knows it :eek:. At the time I wasn't thinking about this great community on the forum and all the resources to hand, all that was going through my mind at the time was that Android Studio was developed by Google with probably hundreds of developers behind it, what was I thinking. But then I remembered what it was like for me to create something simple not just in Android Studio but also in Eclipse, those left hand side panes in those IDE's and all the extra coding was a nightmare for me. Now compare the coding in AS compared to the B4X suite of development tools and as far as I'm concerned I had a huge advantage, so I just kept pushing on.

Half way through I was expecting either Imran or Matt to say 'hey I've finished', but thankfully that never happened.

Anyway Erel designs the B4X IDE look and feel and he actually does all the hard work so that we don't have to, closely followed by the library developers and wrappers. Erel keeps up to date as much as humanly possible with all the latest Android news, updates, solutions and issues from Google and he then has to decide how to implement everything that he has learned into B4A for example, he also has to do the same for B4I, B4J and B4R too.

Me, I just took advantage of everybody else's hard work :D, cheers all ;)

Great work!! We all eagerly await a third challenge ;)
There's a famous saying @Lewys Cousins, 'Once bitten twice shy', Imran ignored that saying completely. I can't see it happening as Imran might not be up for it again. If it does happen I would be pushing for some sort of mind game, image memory game or maths memory game. I once released a flags game (with multiple games inside of it) on the Play Store that did really well, but I pulled it as I wanted to add even more games to it, but I never got around to completing the updates, I was just too busy at the time. If we ever went for a third challenge I would want to change it up a bit and definitely do some sort of small game next, we can just use gfx images from free online resources as it would only be for our challenge apps.

If there were ever to be a third challenge, I would definitely be going for a clean third round knock out, no counting to 10 for a TKO :D

Hmm, I might have to call Imran later to give him a chance for revenge...
Last edited:

Peter Simpson

Licensed User
Wow, this is very exciting. If you dont mind me asking. For MySQL, which library did you use from here in the forum? I see that the speed if fairly very good.
Thank you, it was exciting and stressful both at the same time

My MySQL library of choice is no longer available on the forum, the library developer took it off about 18 months ago, but trust me when I say that it's seriously fast. You have to remember that in the video when I filter out the searches, it brings back not just the text results, but the Base64 stored images too, the images are between 250k and about 500k each. So yes in the video it does bring back the online database queries extremely quickly, but the speed is even more impressive without loading the image data as well.

The library solution that I use is based on the official MariaDB library and is excellent. The basic database information is stored in KeyValueStore2 and I obviously use PutEncrypted and GetEncrypted for storing and retrieving the MySQL database information.

I don't use any other solutions as most of them means installing another driver on the server. Not unless the client has an VPN or dedicated server, I find a lot (not all) service providers are reluctant (are not willing) to install an extra driver once MySQL is already installed on their servers.

Fun fact (I don't do this though):
Hey, did you know that if you copy the jSQL library from the internal B4J libraries folder to your B4A external libraries folder, you can use that library to connect directly to an MySQL database. In release mode you need to use DisableStrictMode but it works great and is seriously fast too. It only takes a few lines of code to get running, I tried it out one day because I was bored and was wondering about it. I was seriously impressed with the speed and ease of use, but I DO NOT and WOULD NOT use this for an app solution, it was just for fun and to ease my curiosity.

I wonder why @Erel didn't create an easy to use MySQL solution like the B4J solution but instead for B4A (probably for security reasons on the play store), a solution that does not require asking service providers to install extra drivers. Not all businesses have VPN or dedicated servers that they control, actually over 99% of businesses have their websites on shared servers which are hosting hundreds of sites per server, that stat can be found on the net.

I have my own dedicated 2TB SSD server with 64GB of ram and 2TB of SSD RAID, I host my clients databases, so I can easily use for example Erels jRDC2 or JdbcSQL solutions, but those solution are not for me or for my clients either. A lot of my clients already have MySQL databases with a supplier, those suppliers can be a pain to deal with, my clients might already have some sort of bespoke Windows software or e-commerce website using that MySQL database and moving their database to my server is not always an option, even though I have done that before.

What @Erel says about solutions like what I use is.
- Insecure - it will be quite simple for a hacker to get the username and password and directly access the database.
A. All my solution are bespoke in-house solutions, no Play Store apps. If a hacker really wanted the data they would most probably need to steal an android device from my clients, or actually spend some time hacking the actual database if they can find it. If IBM, Facebook, Microsoft, The Pentagon and Amazon etc can get hacked (have security issues), then anybody can. Which bedroom hacker would seriously try to steal a device, they might end up with a black eye or broken nose ;)

All my databases have important information encrypted. Using encryption is by its nature a slow process, so I only encrypt names, addresses, postcodes and phone numbers, the end user can't really tell the difference speed wise so all is good there. The information sent to the server is the same information that would be sent via for example MySQL studio on Windows, I repeat that my apps are bespoke and ARE NOT on the Play Store.

- Hard to maintain - changes to the database design will require updating the app.
A. Not a problem for me, plus any DB changed only happens if I update the app anyway. Why would I change the database without changing/updating the app. I get paid for adding new features, thus I add new tables to the database if need be. Anyway any new tables and columns are usually created as my clients needs them, so yes there no issues there either.

- Server and client performance issues - The Jdbc drivers are not optimized for mobile usage.
A. Maybe so but I've never had any speed issues. Fetching results speedwise is almost on par with my windows development laptop, now populating tables (xCLV) is nowhere near as fast as let's say a DataGridView, but I would never expect a mobile device to be anywhere near the processing speeds of computer, not even an 7th generation i3. But for what it is, speed wise as you can see from the video the MySQL library that I use and Erels xCLV with LL works great, don't forget I'm loading and decrypting large Base64 images at the same time as I didn't have time to optimise the images down to size (about 50k):)

I have both a huge Ford and a Huge Vauxhall parts distributors using my Android solutions, both their databases are we'll over 1GB in size, my bespoke Android apps are fully optimised and have never had any serious issues whatsoever with performance, if they had these clients would let me know. It's not like they load all the data at once like M$ Excel does.

- Reliability issues due to unstable connectivity.
A. I've not had any serious complaint about connections to my servers considering how long I've been doing this for, my clients have had internet service provider issues but nothing to do with my services, plus the same connectivity issues would happen with Erels solution (If you can't reach the IP address of the server then you can't reach it, it's as simple as that). Yes their are issues once in a blue moon but nothing too serious. My supplier once had a main switch go down, also they had a new antivirus box put in place that interfered with my server but nothing too serious, but even with Erels solution the exact same small issues would have happened. There's been a few times when I can't reach b4x.com for a while via multiple connection and suppliers, that's happened more than I've ever had issues in my server. At home I have 2 separate broadband suppliers (Talk Talk and Virgin Internet), I have two simply because if one ever goes down I can quickly switch to the other one. Nothing is perfect, but luckily over the years I've not had any reasons for my clients to moan about my services, I'm pleased about that. So I'll just keep using the MariaDB solution until hopefully @Erel one day adds MySQL to the standard SQL library in B4A (preferably with a warning about not using that solution for Play Store apps) which I would not do anyway. Hmm, maybe for saving high scores in online games, but once again that would depend on what drivers are installed on the server lol :p

Oops, sorry for the long response (rant)...
Last edited:


Licensed User
@Peter Simpson , thanks for the rant, very informative. I'm glad there are people like you here to share their experiences so that we also know. As a person you always learn from the best and at times reinventing the wheel might be necessary and sometimes not. Im glad I asked because you have been kind to open up and I learned a lot again. Thanks a million.


Licensed User

Peter Simpson

Licensed User
That solution needs a separate driver installing on the server if I remember correctly. Did you even read my rediculously long and unnecessary response above, I don't like installing extra drivers if there are already drivers on a server, why reinvent the wheel.

But saying that, NASA have infact reinveted the wheel for exploring other planets with Rovers like Mars etc. The wheel changed shape and does not use rubber so it can't get a puncture and it is lighter than traditional wheels, it is basically a wheel with holes already included. Anyway, if I need to install a separate driver on a server then I have no interest, well not unless there are absolutely no other solutions available Mr @OliverA ;)

Cheers and you have a nice chillaxing day.


Licensed User
Thanks for the heads up again. For security reasons the lib should be used in in-house apps. I’m looking for a lib that I can use for MySQL that has decent speeds for apps for the store. I have been using php all this time because I had to produce both apps for iOS and android and porting my app was fairly easy for that. Is there something decent that one can use on both platforms without the need for phping around?


Peter Simpson

Licensed User
Very long rant and for no good reason:

JdbcSQL - Directly connect to remote databases

Nothing is required on the server...

(I admit that I haven't read all your post)
I was originally saying that it would be good to have it like B4J, just there (something like initialize2) without searching the forum for jdbcSQL, there are already a lot of these on here and it gets confusing.

Anyway some unrelated news.
I finished rebuilding and upgrading my 497 BHP Cossie last weekend, so I'm now going out to the track to test it. If all goes well I can advertise it and sell it next week. It's too fast for main roads and there no need for me to be paying 3 lots of car insurance.

Anyway I'm off, got to be at the track for 3:30. Then I'll be back, as Arnie says :)


Staff member
Licensed User
I was originally saying that it would be good to have it like B4J, just there (something like initialize2) without searching the forum for jdbcSQL
It will not be added to the standard SQL library as the B4A SQL library is built over a completely different API (SQLite is natively supported by Android).

without searching the forum for jdbcSQL, there are already a lot of these on here and it gets confusing.
There aren't so many options. I recommend watching jRDC2 video tutorial: https://www.b4x.com/android/forum/t...-rdc-remote-database-connector.61801/#content

The various options are explained.