You are here: Hello » Tutorials


Here is a list of tutorials written by me. Hope you will find something usefull


Compile APK online

It was long time i was dreaming about ability to compile apk online. So this blog post (tutorial) will be how to prepare C9 (C9 was bought by Amazon AWS and does not really offer free containers any more) or Goorm online IDE or any similar based on ubuntu linux to be able to develop online. This should also work on local linux installation or even Windows subsystem for Linux if you are on Win10

This post will not be about “upload my zip online and get apk”. You have to set up environment in virtual server. My suggestion is go with Goorm IDE they give you up to 5 containers for free where you can set up different environment for various development things.

First of all, create new empty ubuntu box and resize it to 1Gb RAM and 5GB storage goorm gives you 1GB ram and 10GB storage out of the box. Simple APK compile stull will require about 1GB of storage, but if you decide to go on gradle dependency management system- storage will grow to 2.5GB.

I prepending everyhing with sudo command, in case any permission will be missing.

→


Multiple Screens

All Android graphical user inteface elements are fitted into Screens. Your simple application may have just one screen. More sophisticated apps may have multiple screens. For example About, Help or Settings screens together with main app screen. Sometimes you need to pass information from one screen to another. This tutorial will cover this. It is about screens usage and passing data between them.

→

2014/02/04 20:18 · 1 Comment

Radio Button in AppInventor

screenshot.02-04-2012_2010.55.59.jpgThere is no RadioButton in AppInventor's components list, so you have to build it yourself. I've saw youtube tutorial how to build RadioButtons based on CheckBoxes. I didn't realy liked that work-a-round, though it works. But that tutorial trow me idea how to build more RadioButton looking ones, out from Images and regular Buttons

→


separator2.jpg If your applications requires to separate different parts of GUI elements, you can use separator for this. AppInventor does not have this by default, so you have to work-a-round it. Here is how: To create a separator in your android app, just use simple Label component. Set BackgroundColor to black (or whatever else that fits your theme), empty the text field, width- Fill parent, and Height- 1 pixel. And here you have a separator in your application.

2014/02/04 20:18


JQuery getScript not working in Cordova

Creating Cordova (formerly known as PhoneGap ) application aimed to work with 1.6+ Android I've faced strange problem. Android 4.0.* versions devices does not load script via jQuery command getScript. And this was only in 4.0.* version devices

→

2014/02/05 16:31 · 0 Comments


Pure python and very simple event management library

In event driven programming events are crucial. My requirements was Micropython platform on ESP32 micro-controller, so i could not use any other events library out-there. I've stumbled one very basic, very simple library and gave it a try… and it worked out-of-the-box for my case. When testing various event management libs out there I've stumbled on something similar, but it did not worked within classes. Python is nothing but classes everywhere :)

I was testing and extended this very simple python script, that perfectly works as main element in event driven development.

Strengths of library:

  • Observer can be declared before event type is created
  • Events can be fired even if there is no observers.
  • Works as pure python script
  • Works on micropython platform
  • Event name can be any string

I'm using this solution for event for timer, that fires each second and observe “ticker” where i need to update clock. I use clock in multiple places in my micropython script and i can get away with just one hardware timer used.

Honorable mentions goes to Pithikos from StackOverflow this answer

I have extended this library with possibility to forget event.
class Observer():
    _observers = []
    def __init__(self):
        self._observed_events = []
    def observe(self, event_name, callback_fn):
        self._observed_events.append({'event_name': event_name, 'callback_fn': callback_fn})
    def forget(self, event_name):
        for dict_item in self._observed_events:
            for key, val in dict_item.items():
                if val == event_name:
class Event():
    def __init__(self, event_name, *callback_args):
        for observer in Observer._observers:
            for observable in observer._observed_events:
                if observable['event_name'] == event_name:

Here is example of how to use this library
import EventObserver
# class object MUST inherit Observer object if you use it within class
class Room(Observer):
    def __init__(self):
        print("Room is ready.")
        Observer.__init__(self)  # DON'T FORGET THIS
        # observer can be declared already in class init method with following line
        # this.observe('someone sneezed', this.someone_sneezed)
    def someone_arrived(self, who):
        print("{} has arrived!".format(who))
    def someone_sneezed(self, who):
        print("{} has just sneezed!".format(who))
# Observe for specific event
room = Room()
room.observe('arrived', room.someone_arrived)
room.observe('sneezed', room.someone_arrived)
# Fire some events
Event('left', 'John')       # no events are attached to event "someone left" 
Event('arrived', 'Lenard')  # will output "Lenard has arrived!"
Event('sneezed', 'Jenny')   # will output "Jenny has just sneezed!"
# Remove known event
# no events based on 'someone arrived' will be fired

Quick tips

2014/02/04 20:18  
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported - Nemokamas lankytojų skaitliukas XHTML