This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GET DEVICE PROTECTED CONTEXT | |
Context applicationContext = getApplicationContext(); | |
Context safeContext = ContextCompat.createDeviceProtectedStorageContext(appicationContext); | |
// MOVE DATA FROM CREDENTIAL TO DEVICE STORAGE | |
Context.moveSharedPreferencesFrom(); | |
Context.moveDatabaseFrom(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConstantState constantStateDrawableA = drawableA.getConstantState(); | |
ConstantState constantStateDrawableB = drawableB.getConstantState(); | |
if(constantStateDrawableA.equals(constantStateDrawableB)) { | |
// do something | |
} else { | |
// do something else | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface GeofenceCallback { | |
void onGeofenceResultAvailable(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Display display = getWindowManager().getDefaultDisplay(); | |
View view = findViewById(R.id.YOUR_VIEW_ID); | |
view.measure(display.getWidth(), display.getHeight()); | |
view.getMeasuredWidth(); // view width | |
view.getMeasuredHeight(); //view height |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GoogleLocationApiManager implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, | |
ResultCallback<LocationSettingsResult>, LocationListener { | |
private static final String TAG = GoogleLocationApiManager.class.getSimpleName(); | |
private static final int LOCATION_REQUEST_INTERVAL = 10000; | |
private static final int LOCATION_REQUEST_FASTEST_INTERVAL = 5000; | |
private static final int LOCATION_REQUEST_PRIORITY = LocationRequest.PRIORITY_HIGH_ACCURACY; | |
private GoogleApiClient mGoogleApiClient; | |
private LocationSettingsRequest.Builder mLocationSettingsRequestBuilder; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v7.widget.Toolbar | |
android:id="@+id/your_toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:popupTheme="@style/AppTheme.PopupOverlay" > | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/your_icon" |