Skip to content

Instantly share code, notes, and snippets.

public class GeofencingManager implements ResultCallback<Status>{
private static final String TAG = GeofencingManager.class.getSimpleName();
private GoogleLocationApiManager mGoogleLocationApiManager;
private GeofenceCallback mGeofenceCallback;
private List<Geofence> mGeofenceList = new ArrayList<>();
private PendingIntent mGeofencePendingIntent;
private Context mContext;
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:textAlignment="textStart"
android:layout_gravity="start"
android:text="Test label" />
ConstantState constantStateDrawableA = drawableA.getConstantState();
ConstantState constantStateDrawableB = drawableB.getConstantState();
if(constantStateDrawableA.equals(constantStateDrawableB)) {
// do something
} else {
// do something else
}
public static boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
Drawable.ConstantState stateA = drawableA.getConstantState();
Drawable.ConstantState stateB = drawableB.getConstantState();
// If the constant state is identical, they are using the same drawable resource.
// However, the opposite is not necessarily true.
return (stateA != null && stateB != null && stateA.equals(stateB))
|| getBitmap(drawableA).sameAs(getBitmap(drawableB));
}
public static Bitmap getBitmap(Drawable drawable) {
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.directboot">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
// GET DEVICE PROTECTED CONTEXT
Context applicationContext = getApplicationContext();
Context safeContext = ContextCompat.createDeviceProtectedStorageContext(appicationContext);
// MOVE DATA FROM CREDENTIAL TO DEVICE STORAGE
Context.moveSharedPreferencesFrom();
Context.moveDatabaseFrom();
package com.kostovtd.appshortcuts;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<!-- SETTINGS SHORTCUT -->
<shortcut
android:shortcutId="settings"
android:enabled="true"
android:shortcutShortLabel="@string/settings_shortcut_short_label"
android:shortcutLongLabel="@string/settings_shortcut_long_label"
android:shortcutDisabledMessage="@string/settings_shortcut_disabled_msg">
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kostovtd.appshortcuts">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
<style name="CustomButtonStyleWaikawaGrey" parent="Theme.AppCompat">
<item name="colorButtonNormal">@color/waikawa_grey</item>
</style>