Skip to content

Instantly share code, notes, and snippets.

Avatar

Gigigo Android Development Team GigigoGreenLabs

  • Gigigo
  • Madrid
View GitHub Profile
@GigigoGreenLabs
GigigoGreenLabs / CustomWebView
Last active Nov 26, 2015
Call java method in a html page executing the java method in a custom webview
View CustomWebView
@Bind(R.id.webView) WebView webView;
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
//To request the geolocation in the webview
webView.getSettings().setGeolocationDatabasePath(getContext().getFilesDir().getPath());
webView.setWebChromeClient(new WebChromeClient() {
@GigigoGreenLabs
GigigoGreenLabs / PackageUtils.java
Last active Nov 26, 2015
Check if a app is installed and go to the market if not. We have to pass the package of the app in the param.
View PackageUtils.java
public class PackageUtils {
public static void startNewActivity(Context context, String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
if (intent == null) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + packageName));
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
@GigigoGreenLabs
GigigoGreenLabs / LocaleUtils.java
Last active Nov 7, 2019
Change the locale language inside the app
View LocaleUtils.java
import android.app.Application;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.view.ContextThemeWrapper;
import java.util.Locale;
public class LocaleUtils {
@GigigoGreenLabs
GigigoGreenLabs / AddContactToContactDevice.java
Last active Nov 10, 2015
Añadir contacto añadiendolo directamente en la agenda, y con un Intent sin necesidad de pedir permisos
View AddContactToContactDevice.java
import android.content.ContentProviderOperation;
import android.content.Context;
import android.provider.ContactsContract;
import android.util.Pair;
import java.util.ArrayList;
import java.util.List;
public class AddContactToContactDevice {
@GigigoGreenLabs
GigigoGreenLabs / CheckPermissions.java
Last active Nov 10, 2015
Check M Permissions class. This class has to grow
View CheckPermissions.java
import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
public class CheckPermissions {
public static final int REQUEST_CONTACTS = 1273;