Skip to content

Instantly share code, notes, and snippets.

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:

@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active July 4, 2024 13:42
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ayushhgoyal
ayushhgoyal / test_gcm.php
Last active October 1, 2015 15:46 — forked from phpfiddle/fiddle_090817.php
[ Posted by Ayush ] This is php code to test android push notifications (GCM) online. Just replace API key and device ids. It will send a notification with key "alert". It can be executed here: http://phpfiddle.org/main/code/c12cf0475e97f3cf19c1 (Shortcut: F9)
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'AIzaSyDD5cwKE6O252bVA766Lyo2cQhG7RbShWA' );
$registrationIds = array("erKXJiDIdiY:APA91bE3N0Bfh6e7tpIT2qcHBD_vqg6ObMQHyrbXEAf6MQqeHcGSauArLzoQRvWb7VpHY_hReEdfw3WxU5Ybk95dWnGT2KAQmC9cHAajuDQx5kJu1Ic2QJKuu3vYNtuRAo6edfuMrbJj" );
// prep the bundle
@shakalaca
shakalaca / build.gradle
Last active December 30, 2022 08:34
move & rename APK files
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.6'
}
}
task wrapper(type: Wrapper) {
@ayushhgoyal
ayushhgoyal / ChatHeadService.java
Last active December 18, 2015 11:59
Facebook chat heads in android application.
// I forked this code from- http://www.piwai.info/chatheads-basics/
// Chat head is displayed from a service.
// uses a permission: <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
// This is a service so it needs to be declared in manifest: <service android:name=".ChatHeadService" />
// Whenever you need to display the chat head, just start the service
// example: startService(new Intent(context, ChatHeadService.class));
public class ChatHeadService extends Service {
private WindowManager windowManager;