Skip to content

Instantly share code, notes, and snippets.

View hiwanz's full-sized avatar
💭
I may be slow to respond.

丸子 hiwanz

💭
I may be slow to respond.
View GitHub Profile
@hiwanz
hiwanz / detect-console.html
Created November 19, 2014 06:46
Detect if browser console is opened.(Chrome 38.0.2125.111 m,IE 11 is tested)
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>console track</title>
</head>
<body>
console status: <span id="stat"></span>
<script>
function isConsoleOpen() {
@hiwanz
hiwanz / timer.java
Created October 1, 2014 15:28
An Android timer demo call
//need to import android.os.Handler;
final Handler h = new Handler();
h.postDelayed(new Runnable()
{
private long time = 0;
@Override
public void run()
{
// do stuff then
@hiwanz
hiwanz / ShakeListener.java
Last active July 12, 2016 06:17
手机摇一摇类,调用代码: ShakeListener shakeListener = new ShakeListener(this); shakeListener.setOnShakeListener(new ShakeListener.OnShakeListener() { //调用setOnShakeListener方法进行监听,摇晃手机输出信息 public void onShake() { Log.v("debuginfo","shakeing"); } });
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
public class ShakeListener implements SensorEventListener {
//速度阈值,当摇晃速度达到这值后产生作用
private static final int SPEED_SHRESHOLD = 2500;