classes • Variables, methods and class names with meaningful names • Comment only when (self documenting) code itself fails to express what is done • Document why is something done, now what • Avoid any duplication • Consistent formatting and style
calculateWage() Variables: lowerCamelCase ex. int totalPayroll = 10000; Note: Don’t use m prefix for local variables ex. mTotalPlayroll Constants: uppercase characters separated by underscores, ex. final int MONTHS_IN_A_YEAR = 12;
is created and passed to the method. All primitive data types are passed by value (byte, short, int, long, float, double, char, boolean) Pass by reference: When passing object, you're passing an object reference. Note: Each primitive has also a wrapper object, ex. int -> Integer which acts as reference type Note2: String object is specially handled: object which is not changeable
reference is used to refer to a child. That’s why this is correct: Context context = getActivity(); Example: class Cat extends Animal Cat cuteKitten = new Cat(); Animal referenceToAnAnimal = cuteKitten;
run everywhere Reality (most cases): write once, suck everywhere Downsides: • Slow • May be locked to a certain closed source framework • UI looks the same on every platform • Another layer of complexity (black box)
Chrome (Beta) to run Android apps on Windows/OS X/Linux (Google Chrome plugin) Android wearable Glasses, watches, what next? Android auto Car manufacturers use Android as multimedia platform. Manufactures on board: Audi, Ford, Honda, Mazda, Nissan, Volkswagen, Volvo etc.
used in internet of things devices (connected devices with limited resources ex. door locks, lamps etc.) Android apps porting to Windows Port apps to windows 10 (includes Windows Phone) Minimal changes needed.
Infringe copyright • Keyword spam If you do: • Auto banned by robots • Banned for life • No way to get feedback why where you banned: Google support is nonexistent
manage 1+ developers per project = complicated. Workflow has to structured and rules needed to avoid (code)conflicts and work efficiently How we develop: 1. Each fix or feature is developed on feature branch 2. If completed, pull request and submitted for review (by other developer in the project) 3. If code review passed, merge into main branch 4. Make a release and send to testing 5. If tests passed = Job done
12 jun Positions: software engineer in test or developer About us: ~10 employees, office in Telliskivi loomelinnak Very interested in people who have completed this subject Contact: [email protected]
Easy with primitive data types but what if object with 40 properties? Setting object as public static = bad practise (potential bugs, hard to debug) Solution: Make object Parceable • CustomObject implements Parcelable • intent.putExtra(KEY, myCustomObject) Note: Making object Serializable is not recommended due to performance penalty
returns null on tablets and needs an extra permission • Write UUID to internal storage - could be wiped by user Solution: String uniqueId = Secure.getString(getContext(). getContentResolver(), Secure.ANDROID_ID); Notes: • Survives app uninstalls and installs • Multiple users each have unique id • Does not survive device reset
are lost Solution: Set android:configChanges="orientation|screenSize" in Manifest Note: Handling the configuration change yourself will make it harder to use alternative resources
app being on background for a long time? Solution: Settings >> Developer Options (needs to be enabled) >> Don’t keep activities Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). Note: If objects are set public static they won’t be destroyed
you use setText(123), the method TextView.setText(int resourceId) is called not TextView.setText(CharSequence text) Solution: setText(123+””) or setText(String.valueOf(123)) or setText(Integer.toString(123))
Activity lifecycle onCreate - create UI here onResume - activity is active onPause - activity is partially covered onStop - activity in background Backstack History of activities
for accessing resources (screen drawing, writing to internal storage etc.) Intent Something going to be done (mostly Activity start). May include data for transfer. Intent-Filter Captures system wide implicit intents
user interface. Many similar lifecycle callbacks as activity. Can be combined, added, removed etc. in UI Layout • Reference resources by ID not by file path • Can use OS resources by prefixing with “android” Alternative resources • Automatically built in system for configuration based resources • Divide resources into different folders in res folder and system automatically applies correct one
notification that something happened • Can be global or local Broadcast Receiver • Receives broadcasts (system wide or local) • Allows to implement custom logic when broadcast is received
value and by reference Polymorphism Native HTML alternatives Future of Android Google play publishing Workflow at Applaud Practice at Applaud Top everyday problems Rehearsal of everything