Skip to content

Instantly share code, notes, and snippets.

View alcarazolabs's full-sized avatar
:octocat:
Focusing

Freddy Alcarazo alcarazolabs

:octocat:
Focusing
View GitHub Profile
@alcarazolabs
alcarazolabs / Permissions.md
Created March 26, 2021 01:23 — forked from mohamedebrahim96/Permissions.md
Requesting Runtime Permissions In Android M And N, Starting from Android Marshmallow (API 23), users will be asked for permissions while the app is running. This way, a user is able to choose which permissions they should grant without affecting the application flow. In this tutorial I will cover requesting runtime permissions in Android M and N…

Starting from Android Marshmallow (API 23), users will be asked for permissions while the app is running. This way, a user is able to choose which permissions they should grant without affecting the application flow. In this tutorial I will cover requesting runtime permissions in Android M and N, how to perform a request, get its result and then handle it.

@alcarazolabs
alcarazolabs / MQTTConsumer.java
Created April 26, 2022 15:52 — forked from msvitok77/MQTTConsumer.java
MQTT Sender/Consumer
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class MQTTConsumer {
public static void main(String[] args) {
String topic = "sah/+/#";
fun <T: ViewModel> T.createFactory() : ViewModelProvider.Factory {
val viewModel = this
@Suppress("UNCHECKED_CAST")
return object :ViewModelProvider.Factory{
override fun <T : ViewModel?> create(modelClass: Class<T>): T = viewModel as T
}
}