当前位置: 编程技术>移动开发
本页文章导读:
▪判断银屏是否锁定 判断屏幕是否锁定
AndroidManifest.xml加两个权限
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission.........
▪ TimerTask 推延一秒执行 TimerTask 延迟一秒执行
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
getData();
}
};
timer.schedule(task, 1000);
......
▪ 震下手机 震动手机
/*
* 根据客户设置是否震动
* private Vibrator vibrator;
* vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
* PublicUtil.vibrator(this, vibrator);
* /
public static void vibrator(Context context, Vibrator .........
[1]判断银屏是否锁定
来源: 互联网 发布时间: 2014-02-18
判断屏幕是否锁定
AndroidManifest.xml加两个权限 <uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission> <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
public static boolean isWallPaperLocked(Context context) { KeyguardManager keyguardManager = (KeyguardManager) context .getSystemService(context.KEYGUARD_SERVICE); return keyguardManager.inKeyguardRestrictedInputMode(); }
[2] TimerTask 推延一秒执行
来源: 互联网 发布时间: 2014-02-18
TimerTask 延迟一秒执行
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
getData();
}
};
timer.schedule(task, 1000);
[3] 震下手机
来源: 互联网 发布时间: 2014-02-18
震动手机
/* * 根据客户设置是否震动 * private Vibrator vibrator; * vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE); * PublicUtil.vibrator(this, vibrator); * / public static void vibrator(Context context, Vibrator vibrator) { SharedPreferences preferences = context.getSharedPreferences( SYSTEM_SETTINGS, Context.MODE_PRIVATE); boolean openVibrator = preferences.getBoolean("openVibrate", true); if (!openVibrator) return; vibrator.vibrate(500);//震动0.5s }
最新技术文章: