jueves, 9 de septiembre de 2021

Android: Coroutines

Pieces

  • Job
  • Dispatcher
  • Scope

Job

Conceptually, a job is a cancellable thing with a life-cycle that culminates in its completion. Jobs can be arranged into parent-child hierarchies so that cancellation of a parent leads to an immediate cancellation of all its children.

Dispatcher

The dispatcher sends off coroutines to run on various threads (for example, Dispatchers.Main, Dispatchers.IO

Scope

The scope combines information, including a job and dispatcher, to define the context in which the coroutine runs.

Example (on preview)

miércoles, 8 de septiembre de 2021

Android: LiveData and Room: Setup

Setup

Project's gradle 
Module's gradle


Room

Room has three main components of Room DB :

  • Entity
  • Dao
  • Database
  1. Entity - Represents a table within the database. Room creates a table for each class that has @Entity annotation

    1. @PrimaryKey(autoGenerate = true)
    2. @ColumnInfo(name = “column_name”)
    3. @Ignore — field will not be persisted by Room
    4. @Embeded — nested fields can be referenced directly in the SQL queries.

  2. Dao - DAOs are responsible for defining the methods that access the database.

  3. Database - Contains the database holder and serves as the main access point for the underlying connection to your app’s persisted, relational data.

Example

(See on preview for gists visibility)
  1. SleepNight entity

  2. Dao

  3. Database

viernes, 20 de agosto de 2021

Android: Vector drawables

Since vector drawables were added on api 21 if you have vector drawables and have support for api < 21 the system will generate pngs for all systems below 21. To avoid this:

 1. Enable the use of support library for vector drawables in build.gradle file (app level):

vectorDrawables.useSupportLibrary = true

2. Use app:srcCompat in the image tag in the layout file:

app:srcCompat="@drawable/empty_dice"

3. You’ll also need to add the namespace to the root of the layout:

xmlns:app="http://schemas.android.com/apk/res-auto"

viernes, 18 de diciembre de 2020

lunes, 9 de noviembre de 2020

Android: Internal Realease

 

Create internal release

1) Google play console
2) Create application if required
3) Release management > app releases > internal test track > manage
4) Create release
5) In “Android App Bundles and APKs to add” upload your apk, check that there are no grayed ticks on the menu of the left (the one titled “Google Play Console”)
6) Complete the form and click save
7) Click review

IMPORTANT: Remember that if you are going to upload an apk with build type “debug” 


Related: View url

1) Release management > app releases > internal test track > manage 
2) In “Manage testers” tap on the dropdown button
3) You will have the url at the expanded view, at the bottom, named “Opt-in URL”, you have to accept the invitation before moving forward
4) Once you done that you can go to “Dashboard” at the top, just below the app name you will have a button named “VIEW ON GOOGLE PLAY”

lunes, 28 de septiembre de 2020