Skip to content

Instantly share code, notes, and snippets.

@allenchi
allenchi / gist:6c335428321b8a7530f6
Created May 6, 2015 06:46
Check Google Play Service
// check if a compatible play services is available on the device
// if not, show a dialog that takes the user to Google Play Store
// to install the required play service
private boolean checkPlayServices() {
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (status != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
showErrorDialog(status);
} else {
Toast.makeText(this, "This device is not supported.",
/**
* Location Intent Service
*/
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.support.v4.content.LocalBroadcastManager;