Skip to content

Instantly share code, notes, and snippets.

View dekzitfz's full-sized avatar
🎯
Focusing

Adi Andrea dekzitfz

🎯
Focusing
View GitHub Profile
@dekzitfz
dekzitfz / AndroidServiceStatus.java
Created August 1, 2016 01:37
check if an android service is running or not
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@dekzitfz
dekzitfz / AndroidSMSListener.java
Created August 1, 2016 01:43
Detect incoming sms in android
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony;
import android.telephony.SmsMessage;
import android.util.Log;
@dekzitfz
dekzitfz / checkGooglePlayServicesAvailable.java
Last active August 20, 2016 11:55
Android: Check whether Google Play Services are installed and current
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
include ':app'
public final class SunshineWeatherUtils {
private final static String TAG = SunshineWeatherUtils.class.getSimpleName();
public static String formatTemperature(Context context, double temperature) {
int temperatureFormatResourceId = R.string.format_temperature;
return String.format(context.getString(temperatureFormatResourceId), temperature);
}
public static int getSmallArtResourceIdForWeatherCondition(int weatherId) {
@dekzitfz
dekzitfz / strings.xml
Created May 6, 2017 05:28
format temperature
<!-- Temperature format -->
<string name="format_temperature">
<xliff:g id="temp">%1.0f</xliff:g>\u00B0
</string>
@dekzitfz
dekzitfz / GetReadable.java
Last active May 6, 2017 05:31
convert epoch to readable
public String getReadableTime(){
Date date = new Date(dt * 1000L);
DateFormat format = new SimpleDateFormat("MMM dd");
return format.format(date);
}
const express = require('express');
const bodyParser = require('body-parser');
const app = express().use(bodyParser.json());
var request = require('request');
app.post('/paypal-webhooks', (req, res) => {
var summary = req.body.summary;
var fee = req.body.resource.transaction_fee.value;
var id = req.body.resource.parent_payment;
@dekzitfz
dekzitfz / .gitlab-ci.yml
Created June 18, 2018 08:24
Gitlab CI for Firebase Test Lab
image: jangrewe/gitlab-ci-android
stages:
- build
- test
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew