Android 34

How to use synthetic property in Kotlin Android Extension

Issue #555

Synthetic properties generated by Kotlin Android Extensions plugin needs a view for Fragment/Activity to be set before hand.

In your case, for Fragment, you need to use view.btn_K in onViewCreated

override fun onCreateView(inflater: …

How to access view in fragment in Kotlin

Issue #497

Synthetic properties generated by Kotlin Android Extensions plugin needs a view for Fragment/Activity to be set before hand.

In your case, for Fragment, you need to use view.btn_K in onViewCreated

override fun onCreateView(inflater: …

How to show error message like Snack Bar in iOS

Issue #472

Build error view

Use convenient code from Omnia

To make view height dynamic, pin UILabel to edges and center

swift
import UIKit

final class …

How to structure classes

Issue #466

iOS

text
View Controller -> View Model | Logic Handler -> Data Handler -> Repo

Android

text …

How to add AdMob to Android app

Issue #431

Use AdMob with Firebase

build.gradle

groovy
buildscript {
    repositories { …

How to do launch screen in Android

Issue #397

We recommend that, rather than disabling the preview window, you follow the common Material Design patterns. You can use the activity’s windowBackground theme attribute to provide a simple custom drawable for the starting activity. …

How to add header to NavigationView in Android

Issue #396

Use app:headerLayout

xml
<com.google.android.material.navigation.NavigationView
    android:layout_width="wrap_content" …

How to create bounce animation programmatically in Android

Issue #383

Right click res -> New -> Android Resource Directory, select anim and name it anim Right click res/anim -> New -> Android Resource file, name it bounce

xml …

How to use point in dp programmatically in Android

Issue #382

kt
import android.content.Context

fun Int.toDp(context: Context?): Int {
    if (context != null) {
        val scale = context.resources. …

How to create constraints programmatically with ConstraintLayout in Android

Issue #381

From API < 17, there is ViewCompat.generateViewId() For API 17, there is View.generateViewId()

Note that to use ConstraintSet, all views under ConstraintLayout inside xml must have unique id

kt …

How to use custom font as resource in Android

Issue #380

Downloadable fonts

https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts

Android 8.0 (API level 26) and Android Support Library 26 introduce support for APIs to request fonts from a provider application instead of …

How to get Hacker News top stories using parallel coroutine and Retrofit

Issue #379

kt
interface Api {
    @GET("topstories.json?print=pretty")
    suspend fun getTopStories(): List<Int>

    @GET( …

How to show generic list in Fragment in Android

Issue #378

After having a generic RecyclerView, if we want to show multiple kinds of data in Fragment, we can use generic.

We may be tempted to use interface or protocol, but should prefer generic.

kt …

How to use Product Hunt GraphQL API with Retrofit

Issue #370

Define response model

kt
import com.squareup.moshi.Json

data class Response(
    @field:Json(name="data") val data: ResponseData
)

data class …

How to get trending repos on GitHub using Retrofit

Issue #367

text
https://api.github.com/search/repositories?sort=stars&order=desc&q=language:javascript,java,swift,kotlin&q=created:>2019-08-21 …

How to use Retrofit in Android

Issue #366

Code uses Retrofit 2.6.0 which has Coroutine support

app/build.gradle

kt
implementation …

How to use ViewModel and ViewModelsProviders in Android

Issue #363

ViewModels a simple example

https://medium.com/androiddevelopers/viewmodels-a-simple-example-ed5ac416317e

Rotating a device is one of a few configuration changes that an app can go through during its lifetime, including keyboard …

How to inject view model with Koin in Android

Issue #359

app/build.gradle

groovy
implementation "org.koin:koin-core:$Version.koin"
implementation "org.koin:koin-androidx-scope:$Version.koin" …

How to use coroutine LiveData in Android

Issue #358

app/build.gradle

groovy
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha01"
kt …

How to declare generic RecyclerView adapter in Android

Issue #357

generic/Adapter.kt

kt
package com.onmyway133.generic

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import …

How to define version property in gradle

Issue #351

From Gradle tips and recipes, Configure project-wide properties

For projects that include multiple modules, it might be useful to define properties at the project level and share them across all modules. You can do this by adding extra …

How to use Navigation component with DrawerLayout in Android

Issue #349

Screenshot_1565169686

build.gradle

groovy
dependencies {
    classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha05'
} …

How to use ext in gradle in Android

Issue #338

Gradle uses Groovy and it has ext, also known as ExtraPropertiesExtension

Additional, ad-hoc, properties for Gradle domain objects.

Extra properties extensions allow new properties to be added to existing domain objects. They act like …

How to use Gradle Kotlin DSL in Android

Issue #285

kts

settings.gradle.kts

kt
include(":app")

build.gradle.kts

kt

How to run Android apps in Bitrise

Issue #273

Original post https://hackernoon.com/using-bitrise-ci-for-android-apps-fa9c48e301d8


CI, short for Continuous Integration, is a good practice to move fast and confidently where code is integrated into shared repository many times a day. …

How to setup Android projects

Issue #257

checkstyle (Java)

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking …

How to fix ApiException 10 in Flutter for Android

Issue #188

Get error com.google.android.gms.common.api.ApiException: 10 with google_sign_in package.

Read https://developers.google.com/android/guides/client-auth

Certain Google Play services (such as Google Sign-in and App Invites) require you to …

How to fix SSLPeerUnverifiedException in Android

Issue #184

Get error javax.net.ssl.SSLPeerUnverifiedException: No peer certificate in Android API 16 to API 19

Getting started

Read about HTTPS and SSL https://developer.android.com/training/articles/security-ssl Check backend TLS …

Make your own sliding menu on Android tutorial – Part 2

Issue #152

This is the part 2 of the tutorial. If you forget, here is the link to part 1.

Link to Github

In the first part, we learn about the idea, the structure of the project and how MainActivity uses the MainLayout. Now we learn how to actually …

Make your own sliding menu on Android tutorial - Part 1

Issue #151

This post was from long time ago when I did Android


I can’t deny that Facebook is so amazing, they made trends and people want to follow. That is the case of the sliding menu.

Searching many threads on SO, like these create android …

Understanding suspend function in Kotlin Coroutine in Android

Issue #123

Getting to know Coroutine

From https://kotlinlang.org/docs/reference/coroutines.html

To continue the analogy, await() can be a suspending function (hence also callable from within an async {} block) that suspends a coroutine until some …

BuddyBuild and gradle.properties

Issue #109

People advise against storing keys inside build.gradles. We should store them on 1Password and populate our gradle.properties, so don’t track this file in git. Here is .gitignore file

text …

Communication between Fragment and Activity

Issue #108

There’s always need for communication, right 😉 Suppose we have OnboardingActivity that has several OnboardingFragment. Each Fragment has a startButton telling that the onboarding flow has finished, and only the last Fragment shows …