Skip to content

Instantly share code, notes, and snippets.

View robertohuertasm's full-sized avatar
🦀
friendly rustacean

Roberto Huertas robertohuertasm

🦀
friendly rustacean
View GitHub Profile
@robertohuertasm
robertohuertasm / mod.rs
Created December 23, 2018 02:24
azure-function-rust
mod hello;
pub const FUNCTIONS: &[&azure_functions::codegen::Function] = azure_functions::export!{
hello::hello,
};
@robertohuertasm
robertohuertasm / .travis.yml
Last active January 20, 2019 19:37
publish_flutter_package
language: dart
dart:
- stable
os:
- linux
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test # you need this source to get the right version of libstdc++6
@robertohuertasm
robertohuertasm / publish.sh
Created January 20, 2019 19:38
publish_flutter_package
#!/usr/bin/env bash
mkdir -p .pub-cache
cat <<EOF > ~/.pub-cache/credentials.json
{
"accessToken":"$accessToken",
"refreshToken":"$refreshToken",
"tokenEndpoint":"$tokenEndpoint",
"scopes":["https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/userinfo.email"],
"expiration":$expiration
@robertohuertasm
robertohuertasm / build.gradle
Last active March 18, 2020 00:27
foreground_services
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.jaredrummler:android-device-names:1.1.8'
implementation 'com.github.kittinunf.fuel:fuel:2.1.0'
implementation 'com.github.kittinunf.fuel:fuel-android:2.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1'
@robertohuertasm
robertohuertasm / EndlessService.kt
Last active December 25, 2021 09:21
foreground_services
class EndlessService : Service() {
private var wakeLock: PowerManager.WakeLock? = null
private var isServiceStarted = false
override fun onBind(intent: Intent): IBinder? {
log("Some component want to bind with the service")
// We don't provide binding, so return null
return null
}
@robertohuertasm
robertohuertasm / AndroidManifest.xml
Last active June 30, 2019 11:29
foreground_services
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.robertohuertas.endless">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
@robertohuertasm
robertohuertasm / MainActivity.kt
Created June 30, 2019 11:30
foreground_services
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
title = "Endless Service"
findViewById<Button>(R.id.btnStartService).let {
it.setOnClickListener {
@robertohuertasm
robertohuertasm / restart.sh
Last active July 1, 2019 22:39
foreground_services
adb root
# If you get an error then you're not running the proper emulator.
# Be sure to stop the service
# and force a system restart:
adb shell stop
adb shell start
# wait for the service to be restarted!
@robertohuertasm
robertohuertasm / StartReceiver.kt
Created June 30, 2019 11:32
foreground_services
class StartReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_BOOT_COMPLETED && getServiceState(context) == ServiceState.STARTED) {
Intent(context, EndlessService::class.java).also {
it.action = Actions.START.name
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
log("Starting the service in >=26 Mode from a BroadcastReceiver")
context.startForegroundService(it)
return
@robertohuertasm
robertohuertasm / AndroidManifest.xml
Created June 30, 2019 11:33
foreground_services
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.robertohuertas.endless">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"