Skip to content

Instantly share code, notes, and snippets.


Omkar Tenkale omkar-tenkale

  • FRND
  • India
View GitHub Profile
omkar-tenkale / AndroidManifest.xml
Last active November 20, 2022 23:33
android FileUriExposedException fix view file intent crash with fileprovider approach
View AndroidManifest.xml
gmk57 / Sending events to UI.kt
Last active December 23, 2022 15:50
Sending events to UI with Channel/Flow + custom collector (see my first comment for reasons behind it)
View Sending events to UI.kt
* Starts collecting a flow when the lifecycle is started, and **cancels** the collection on stop.
* This is different from `lifecycleScope.launchWhenStarted { flow.collect{...} }`, in which case
* the coroutine is just suspended on stop.
inline fun <reified T> Flow<T>.collectWhileStarted(
lifecycleOwner: LifecycleOwner,
noinline action: suspend (T) -> Unit
) {
object : DefaultLifecycleObserver {
View Android Interview

Android Interview Questions

Q1: Explain activity lifecycle ☆☆

Answer: As a user navigates through, out of, and back to your app, the Activity instances in your app transition through different states in their lifecycle.

To navigate transitions between stages of the activity lifecycle, the Activity class provides a core set of six callbacks: onCreate(), onStart(), onResume(), onPause(), onStop(), and onDestroy(). The system invokes each of these callbacks as an activity enters a new state.

View Kotlin Interview

Interview Questions


Q1: What is a primary constructor in Kotlin? ☆☆

Answer: The primary constructor is part of the class header. Unlike Java, you don't need to declare a constructor in the body of the class. Here's an example:

ozgurg /
Last active January 26, 2023 16:28
Android Animated Play Pause Button by using AnimatedVectorDrawable
public class PlayPauseView extends AppCompatImageView {
public static final int STATE_PLAY = 1;
public static final int STATE_PAUSE = 2;
private AnimatedVectorDrawableCompat mPlayToPauseAnim, mPauseToPlay;
private Animation mFadeOutAnim, mFadeInAnim;
public PlayPauseView(Context context) {
IARI / AudioUtils.kt
Created March 15, 2019 23:32
get the length of a vorbis/ogg file
View AudioUtils.kt
//4 bytes for "OggS", 2 unused bytes, 8 bytes for length
private const val OGG_OFFSET = 8 + 2 + 4
private val OGGS_BYTES = "OggS".map(Char::toByte).toByteArray()
private val VORBIS_BYTES = "vorbis".map(Char::toByte).toByteArray()
fun ByteArray.slice(start: Int, len: Int) = copyOfRange(start, start + len)
fun calculateOggDuration(oggFile: File): Pair<Int, Int> {
var rate = -1
var length = -1
sidneys /
Created January 20, 2018 11:12
YouTube video stream format codes itags

YouTube video stream format codes

Comprehensive list of YouTube format code itags

itag Code Container Content Resolution Bitrate Range VR / 3D
5 flv audio/video 240p - - -
6 flv audio/video 270p - - -
17 3gp audio/video 144p - - -
18 mp4 audio/video 360p - - -
22 mp4 audio/video 720p - - -
package com.github.irshulx.glitchtext;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
rnagarajanmca / apk install from windows context
Last active September 15, 2021 13:55
Register windows context menu entry to install apk with adb
View apk install from windows context
yanngx / FragmentArgumentDelegate.kt
Last active January 19, 2023 09:26
Fragment arguments without hassle !
View FragmentArgumentDelegate.kt
package be.brol
import android.os.Binder
import android.os.Bundle
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created