Skip to content

Instantly share code, notes, and snippets.

View mediavrog's full-sized avatar

Maik B mediavrog

  • @shackersNFT
  • Germany / Japan
View GitHub Profile
@mediavrog
mediavrog / gist:5625602
Last active March 20, 2024 16:59
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :) Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser
@mediavrog
mediavrog / enable-volley-verbose-logging
Last active March 26, 2017 16:58
Enable verbose logging in Google Volley networking library
# (42f63b0de7318fe1 is a device id)
adb -s 42f63b0de7318fe1 shell setprop log.tag.Volley VERBOSE
@mediavrog
mediavrog / compile-volley
Created August 22, 2013 02:21
Compile Google Volley to JAR
$ git clone https://android.googlesource.com/platform/frameworks/volley
$ cd volley
$ android update project -p .
$ ant jar
// Then, copy bin/volley.jar into your libs/ folder and off you go!
@mediavrog
mediavrog / init_crittercism.java
Last active December 24, 2015 01:19
Setup Crittercism
/*######################
* Crittercism
* crittercism.com
######################*/
JSONObject crittercismConfig = new JSONObject();
JSONObject crittermeta = new JSONObject();
try {
crittermeta.put("screen_name", "" + screen_name);
crittermeta.put("user_id", "" + user_id);
@mediavrog
mediavrog / DecoratedRequestQueue.java
Created October 23, 2013 09:27
Make Volley RequestQueue / ThreadPool work with Espresso Testing library
package com.vuzz.snapdish.test.functional;
import android.os.Handler;
import com.android.volley.Cache;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.google.android.apps.common.testing.ui.espresso.contrib.CountingIdlingResource;
/**
* A dummy request queue which enables us to use the Volley Library properly with Espresso.
package com.yokogoshi.line_intent_test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@mediavrog
mediavrog / build.regen_config.gradle
Created February 5, 2014 05:23
Always rebuild / regenerate the BuildConfig file to reflect changes made to buildConfigField
// always rebuild our build config
tasks.whenTaskAdded { task ->
if (task.name ==~ /generate[\w\W]+BuildConfig/) {
task.dependsOn "clean" + task.name.capitalize()
}
}
@mediavrog
mediavrog / IconizedMenu.java
Last active September 17, 2022 13:17
Android Compatibility popup menu with icons (requires support library v7)
/**
* Seems like the only way to use it currently (as of 10/2018) is through reflection
* see https://resocoder.com/2018/02/02/popup-menu-with-icons-android-kotlin-tutorial-code/
**/
package com.vuzz.snapdish.ui;
import android.content.Context;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.menu.MenuBuilder;
@mediavrog
mediavrog / gist:9363908
Created March 5, 2014 09:18
Tip: Add a junk object to your possibly leaking Listeners, Activities, whatever to make them spottable easier when MATing
private byte[] junk = new byte[10*1024*1024];
@mediavrog
mediavrog / NetworkUtils.java
Created March 18, 2014 08:54
When adding Authorization header for use with HttpConnection, beware of the WRAPPING. A wrapped Authorization header will always return 401./..
// the flag Base64.NO_WRAP is essential
public String generateBasicAuthString() {
return "Basic " + Base64.encodeToString(String.format("%s:%s", Utils.deobfuscate(BuildConfig.USER), Utils.deobfuscate(BuildConfig.PW)).getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}