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.app.Service; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.graphics.BitmapFactory; | |
import android.os.Handler; | |
import android.os.IBinder; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.NotificationCompat; | |
import android.support.v4.app.NotificationManagerCompat; | |
import android.text.TextUtils; |
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.app.Activity; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.support.v4.app.ActivityCompat; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.content.ContextCompat; |
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.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentSender; | |
import android.content.pm.PackageManager; | |
import android.location.Location; | |
import android.location.LocationManager; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.v4.app.ActivityCompat; |
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
Stackoverflow Link: https://stackoverflow.com/a/19968400 | |
Handle uncaughtException, start activity: | |
public class MyApplication extends Application | |
{ | |
public void onCreate () | |
{ | |
// Setup handler for uncaught exceptions. | |
Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler() |
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 FusedLocationHelper implements GoogleApiClient.OnConnectionFailedListener, ResultCallback<Status> { | |
private static final String TAG = FusedLocationHelper.class.getSimpleName(); | |
private Context context; | |
private GoogleApiClient googleApiClient; | |
private Location lastKnownLocation; | |
private LocationUpdateListener locationUpdateListener; | |
// location request parameter | |
private long interval = 0; // time in millisecond | |
private long fastestInterval = 0; // time in millisecond |
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.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentActivity; | |
import android.support.v4.app.FragmentManager; | |
import android.support.v4.app.FragmentTransaction; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.inputmethod.InputMethodManager; | |
import java.util.HashMap; |
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.os.Handler; | |
import android.support.v7.widget.RecyclerView; | |
import android.text.TextUtils; | |
import android.widget.Filter; | |
import android.widget.Filterable; | |
import java.util.ArrayList; | |
public abstract class BaseFilterAdapter<T, S extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<S> implements Filterable { |
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.os.Handler; | |
import android.text.Editable; | |
import android.text.TextWatcher; | |
public abstract class DelayTextWatcher implements TextWatcher { | |
private final long DELAY = 300; // milliseconds | |
private Handler handler = new Handler(); | |
private Runnable runnable = new Runnable() { | |
@Override |
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 ContactHelper { | |
private static final String TAG = ContactHelper.class.getSimpleName(); | |
public static ModelContact getContactDetails(final Context context, String contactId) { | |
ModelContact contact = new ModelContact(); | |
contact.setContactId(contactId); | |
Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, |
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
int xPos = (canvas.getWidth() / 2); | |
int yPos = (int) ((canvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2)) ; | |
//((textPaint.descent() + textPaint.ascent()) / 2) is the distance from the baseline to the center. | |
canvas.drawText("Hello", xPos, yPos, textPaint); | |
https://stackoverflow.com/a/38415380 |
NewerOlder