Skip to content

Instantly share code, notes, and snippets.

View GigigoGreenLabs's full-sized avatar

Gigigo Android Development Team GigigoGreenLabs

View GitHub Profile
@GigigoGreenLabs
GigigoGreenLabs / CustomWebView
Last active November 26, 2015 14:56
Call java method in a html page executing the java method in a custom webview
@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 November 26, 2015 14:43
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.
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 February 15, 2023 12:16
Change the locale language inside the app
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 November 10, 2015 12:15
Añadir contacto añadiendolo directamente en la agenda, y con un Intent sin necesidad de pedir permisos
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 November 10, 2015 08:53
Check M Permissions class. This class has to grow
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;