Skip to content

Instantly share code, notes, and snippets.

@fyhack
fyhack / code
Last active February 10, 2017 02:18
解决 sdk 4.0 以上屏蔽系统输入法以后不显示光标的Bug; Shielding system soft keyboard does not display the EditText cursor Bug.
if (android.os.Build.VERSION.SDK_INT <= 10) { //2.3版本之前使用此方法
edit.setInputType(InputType.TYPE_NULL);
} else { //2.3版本以后用反射方法设置setSoftInputShownOnFocus(4.0)的值解决
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setSoftInputShownOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(edit, false);
@fyhack
fyhack / ANRBroadcastService
Created September 6, 2015 07:29
捕获ANR(在android4.4通过)
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import org.acra.ACRA;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
/**
* ShellUtils
* <ul>
* <strong>Check root</strong>
著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:Mariotaku
链接:https://www.zhihu.com/question/37929529/answer/74172064
来源:知乎
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.view.InputDevice;
public static class GCUtils {
private static final String GC_TAG = GCUtils.class.getSimpleName();
public static final int GC_TRY_COUNT = 2;
// GC_TRY_LOOP_MAX is used for the hard limit of GC wait,
// GC_TRY_LOOP_MAX should be greater than GC_TRY_COUNT.
public static final int GC_TRY_LOOP_MAX = 5;
private static final long GC_INTERVAL = DateUtils.SECOND_IN_MILLIS;
private static GCUtils sInstance = new GCUtils();
private int mGCTryCount = 0;
public static GCUtils getInstance() {
@fyhack
fyhack / fiddle.css
Last active March 15, 2018 01:37 — forked from anonymous/fiddle.css
google map sample
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,