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

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 primary 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 database to an SQLite database.
  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, no horrible layouts.
  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 in this challenge.
  9. The SDK must be set to 26 and above.
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 for clients and between you and me I really 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 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 two 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.

Within an hour I had setup my database connectivity and a few other key features like in the manifest the app colors, ToolStrip resources, permissions etc, I had figured out what I personally thought was the best design layout for my app (the design did change a number of times throughout the challenge), I had also started to create the layouts using the built in designer. Don't forget that we could only use online resources and none of our previously created code base, that would have made the challenge way too easy as it would have become a cut and paste challenge and over in just a few hours.

Deep down I personally already know that I had a HUGE advantage over Imran and Matt, I had this great forum and ALL of its excellent 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 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 faster than I do. I was coding away, Imran was coding away, Matt was coding away too. I was drinking rum and cokes, 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 about 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
  6. ABSOLUTELY NO CHEATING
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 looking 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 like it usually does, as long as it worked I didn't care one little bit. 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 a bush 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 of my 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 replied with 'don't worry about it, you will find a way to get it working, you always do', but I couldn't not this time, 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:

Edited: Please note that on Monday I got the BluetoothManager 2018 update working in less than 10 minutes, please read my response to Erel's post below.

Lets now continue:
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 was located on his laptop and also on his companies servers under developers resources. That was my chance to do a Donald Trump and to cut a good deal with Imran and Matt. The deal that I suggested 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 only, we shook hands and 10 minutes or so later I had implemented some barcode reading code from a previous project of mine and my 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. I actually didn't need to add a barcode scanner routine, I just wanted one in the app.

The home straight, it was game over, but who for?
Have you ever seen that classic 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 thanks to all the resources found on b4x.com. 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 to the others, but instead I sent Imran an email link to Dropbox which was of course the compiled APK file, in turn Imran sent the link to Matt, they installed my app trying it out for themselves. Matt said 'hey what the..., 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 blanked faced and in complete disbelief, he just 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 finish their apps. I had finished my app and I had more features too, both of them just couldn't believe it, I used tabs whilst their apps were popping open new activities left right and centre, Matt used an ugly looking scroll view in his add new stick screen. 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 compressions, 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.

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

The audio is not the best, my throat was not right as I had a cold at the time of recording so the sound is muffled in places and my pronunciation of some words are not clear at all, 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 which I really should never have had, after all I'm now a seasoned veteran when it comes to using B4A these days ;)

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, let's wait and see ;)

Cheers...
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
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).


I recommend watching jRDC2 video tutorial:

The various options are explained.

Different API, yes I get that, makes sense.

Why would I do that, I've told other users to watch that video. Just like other things in this world I choose not to use that solution as I'm more than happy with my current choice, more than :)

Anyway I'm off to balance my 450 Heli blades and to make sure it is ready for competition on Saturday.

Cheers for the responses Mr U...

Edit: Starting from November 2018 I'm now using JdbcSQL for connecting to MSSQL and MySQL online databases.

Thank you @Erel

Enjoy...
 
Last edited:
Top