Skip to content

Instantly share code, notes, and snippets.

@ypresto
ypresto / LimitCacheSizeGlideModule.java
Last active April 27, 2019 16:51
Limit cache size of glide based on total size of Internal Storage implemented on the device.
package com.example.glide;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.util.Log;
import com.bumptech.glide.Glide;
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@cesarferreira
cesarferreira / BlinkAnimation.java
Created May 27, 2014 13:58
Make a View Blink for a desired duration (android)
// Animate a text view
TextView myText = (TextView) findViewById(R.id.textView1);
myText = (TextView)Utils.makeMeBlink(myText,250,20);
// Animate an image view
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView = (ImageView)Utils.makeMeBlink(imageView,250,20);
@carlosefonseca
carlosefonseca / GPXWriter.java
Created August 2, 2013 20:26
Writes a list of timed coordinates to a GPX file.
package pt.beware.core;
import android.location.Location;
import pt.beware.common.utils.Log;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@chandu-io
chandu-io / SaveImageFromUrl.java
Last active July 6, 2018 09:35
java :: save image from url
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class SaveImageFromUrl {
public static void main(String[] args) throws Exception {
String imageUrl = "https://www.google.com/images/srpr/logo3w.png";