Skip to content

Instantly share code, notes, and snippets.

@ccentauri
ccentauri / SignatureChecker.cpp
Last active November 16, 2021 13:05 — forked from wujinyuan/com_example_gist_SignatureChecker.cpp
Get app package signature without JNICALL
jobject getContext(JNIEnv *env) {
jclass jAppAppGlobalsClass = env->FindClass("android/app/AppGlobals");
jmethodID jGetInitialApplication = env->GetStaticMethodID(jAppAppGlobalsClass, "getInitialApplication",
"()Landroid/app/Application;");
jobject jApplicationObject = env->CallStaticObjectMethod(jAppAppGlobalsClass, jGetInitialApplication);
return jApplicationObject;
}
@goodev
goodev / AndroidLogKotlin.xml
Last active November 1, 2021 07:29
Android log live template for kotlin:
<templateSet group="AndroidLogKotlin">
<template name="logm" value="android.util.Log.d(TAG, $FORMAT$)" description="Log method name and its arguments" toReformat="true" toShortenFQNames="true">
<variable name="FORMAT" expression="groovyScript(&quot;def params = _2.collect {it + ' = [$' + it + ']'}.join(', '); return '\&quot;' + _1 + '() called' + (params.empty ? '' : ' with: ' + params) + '\&quot;'&quot;, kotlinFunctionName(), functionParameters())" defaultValue="" alwaysStopAt="false" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="logd" value="android.util.Log.d(TAG, &quot;$METHOD_NAME$: $content$&quot;)" description="Log.d(String)" toReformat="true" toShortenFQNames="true">
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
@pyricau
pyricau / IMMLeaks.java
Last active June 5, 2022 22:46
"Fix" for InputMethodManager leaking the last focused view: https://code.google.com/p/android/issues/detail?id=171190
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import android.os.Looper;
import android.os.MessageQueue;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;