This file contains 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
//Create SHA1 key | |
keytool -list -v -keystore keystore-path | |
//start app from terminal with deeplink | |
adb shell am start -a android.intent.action.VIEW -d '"deeplink_url"' application_id | |
This file contains 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 AlertWrapper { | |
public static void getConfirmDialog(Activity activity, | |
String title, | |
String message, | |
String positiveButtonText, | |
String negativeButtonText, | |
Boolean cancellable, | |
final AlertInterface target) { | |
if (!activity.isFinishing()) { | |
android.support.v7.app.AlertDialog.Builder dialog = new android.support.v7.app.AlertDialog.Builder(activity, |
This file contains 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
/** | |
* Custom Scroll listener for RecyclerView. | |
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e | |
*/ | |
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
public static String TAG = "EndlessScrollListener"; | |
private int previousTotal = 0; // The total number of items in the dataset after the last load | |
private boolean loading = true; // True if we are still waiting for the last set of data to load. | |
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. |
This file contains 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 boolean isTablet() { | |
try { | |
// Compute screen size | |
DisplayMetrics dm = context.getResources().getDisplayMetrics(); | |
float screenWidth = dm.widthPixels / dm.xdpi; | |
float screenHeight = dm.heightPixels / dm.ydpi; | |
double size = Math.sqrt(Math.pow(screenWidth, 2) + | |
Math.pow(screenHeight, 2)); | |
// Tablet devices should have a screen size greater than 6 inches |
This file contains 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
import android.content.Context; | |
import android.content.Intent; | |
import android.hardware.Sensor; | |
import android.hardware.SensorEvent; | |
import android.hardware.SensorEventListener; | |
import android.hardware.SensorManager; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.v7.widget.Toolbar; |
This file contains 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
Intent photoPickerIntent = new Intent( | |
Intent.ACTION_PICK, | |
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); | |
photoPickerIntent.setType("image/*"); | |
photoPickerIntent.putExtra("crop", "true"); | |
photoPickerIntent.putExtra("outputX", 150); | |
photoPickerIntent.putExtra("outputY", 150); | |
photoPickerIntent.putExtra("aspectX", 1); | |
photoPickerIntent.putExtra("aspectY", 1); | |
photoPickerIntent.putExtra("scale", true); |
This file contains 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
private void sendSMS() { | |
String text = getSMSContent(); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) // At least KitKat | |
{ | |
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(this); // Need to change the build to API 19 | |
Intent sendIntent = new Intent(Intent.ACTION_SEND); | |
sendIntent.setType("text/plain"); | |
sendIntent.putExtra(Intent.EXTRA_TEXT, text); |
This file contains 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"?> | |
<!-- | |
Copyright (C) 2015 The Android Open Source Project | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
This file contains 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
// Using an AsyncTask to load the slow images in a background thread | |
new AsyncTask<ViewHolder, Void, Bitmap>() { | |
private ViewHolder v; | |
@Override | |
protected Bitmap doInBackground(ViewHolder... params) { | |
v = params[0]; | |
return mFakeImageLoader.getImage(); | |
} |
This file contains 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
Date now = new Date(); | |
SimpleDateFormat sdf = new SimpleDateFormat("K:mm a"); | |
String formattedTime = sdf.format(now); |
NewerOlder