Skip to content

Instantly share code, notes, and snippets.

View sorianog's full-sized avatar
📱
Honing my Android skills

Gerald sorianog

📱
Honing my Android skills
View GitHub Profile
@sorianog
sorianog / WidgetWithAccelerometer.kt
Created March 7, 2022 09:24 — forked from PSPanishetti/WidgetWithAccelerometer.kt
Spaghetti code for working widget that attached to accelerometer in android.
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*

Interview Questions

Kotlin

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: