Skip to content

Instantly share code, notes, and snippets.

@GBouerat
GBouerat / CursorLiveData.java
Last active March 7, 2020 09:00
First try at LiveData with Cursor and ContentProvider to keep using CursorAdapter
import android.app.Application;
import android.arch.lifecycle.LiveData;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@GBouerat
GBouerat / 01 iterm2-solarized.md
Last active March 1, 2016 08:23 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

@GBouerat
GBouerat / createChooser.java
Last active August 29, 2015 14:01
Filtering Intent chooser
Uri uri = Uri.parse("http://WTF")
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
List<ResolveInfo> resolveInfos = getActivity().getPackageManager().queryIntentActivities(intent, 0);
if (!resolveInfos.isEmpty()) {
ArrayList<Intent> intents = new ArrayList<Intent>(resolveInfos.size() - 1);
for (ResolveInfo resolveInfo : resolveInfos) {
String packageName = resolveInfo.activityInfo.packageName;
if (TextUtils.equals(packageName, BuildConfig.PACKAGE_NAME)) {
continue;
}
@GBouerat
GBouerat / IncrementCurrentPlayerLeaderboardScore.java
Last active November 24, 2022 16:32
Increment current player leaderboard score on Google Play Game Services
public class GameActivity extends BaseGameActivity {
...
private static void updateLeaderboards(final GoogleApiClient googleApiClient, final String leaderboardId) {
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(
googleApiClient,
leaderboardId,
LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_PUBLIC
Hello,
If you previously used the In-app billing sample code to build your in-app billing system, please use the recently-updated sample code as it addresses an exploitable flaw we recently discovered (note that this only affects the helper sample code; the core system and in-app billing service itself was not affected).
The affected applications are those that use the in-app billing sample library (specifically, the IabHelper and the Security classes in the util directory of the in-app billing V3 sample) and do not perform server-side verification.
An update to the sample and library that fixes this vulnerability is now available at code.google.com/p/marketbilling and also through the Android SDK Manager.
To apply the security update:
public static void screenshot(View view, String path) throws Exception {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
File file = new File(path);
file.mkdirs();
file = new File(path, "screenshot_" + System.currentTimeMillis() + ".png");
FileOutputStream fileOutputStream = new FileOutputStream(file);
#!/bin/bash
adb=`which adb`
$adb shell am start -a android.settings.SETTINGS --es :android:show_fragment com.android.settings.NotificationStation
#!/bin/bash
adb=`which adb`
#$adb shell am start -a android.settings.APP_OPS_SETTINGS
$adb shell am start -a android.settings.SETTINGS -e ":android:show_fragment" "com.android.settings.applications.AppOpsSummary"
#!/bin/bash
adb shell "run-as $1 cat databases/$2 > /sdcard/$2"
sleep 1
adb shell "ls -l /sdcard/$2"
sleep 1
adb pull /sdcard/$2 .
[color]
ui = auto
[alias]
graph1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
graph2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
graph = !"git graph2"