- 浏览: 249087 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
-
江恂泽:
楼主 这家伙会把data 拆分开来 转换成day year形 ...
JsonUtil -
mdsp25xhm:
为何没有列表查询功能?
myBatis DAO封装
package com.huawei.voice.activity;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import com.huawei.voice.R;
import com.huawei.voice.util.Parameters;
import com.huawei.voice.util.ToastDeal;
/**
*
* 手机翻转事件处理 待测试
*
* @author mickey_hou
* @version 1.0, 2012-5-17
* @since Tiantian
*/
public class TurningDealActivity extends Activity implements SensorEventListener
{
private SensorManager sensorManager;
private ToastDeal deal = new ToastDeal();
private long mLastUpdateTime;
//private float mLastX, mLastY, mLastZ;
private Context myContext;
public int shakeThreshold = 1500;
@Override
public void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setContentView(R.layout.main);
myContext = TurningDealActivity.this;
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
}
@Override
protected void onResume()
{
super.onResume();
sensorManager.registerListener(this,sensorManager.getDefaultSensor(
Sensor.TYPE_ACCELEROMETER),//TYPE_ACCELEROMETER 传感器类型 :加速度
SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onStop()
{
sensorManager.unregisterListener(this);
super.onStop();
}
public void onAccuracyChanged(Sensor sensor, int accuracy)
{
}
public void onSensorChanged(SensorEvent event)
{
long currentTime = System.currentTimeMillis();
long diffTime = currentTime - mLastUpdateTime;
if (diffTime < Parameters.UPDATE_INTERVAL)
{
return;
}
this.mLastUpdateTime = currentTime;
/*
* 旋转角度测试
*/
float[] values = event.values;
float ax = values[0];
float ay = values[1];
double g = Math.sqrt(ax * ax + ay * ay);
double cos = ay / g;
if (cos > 1) {
cos = 1;
} else if (cos < -1) {
cos = -1;
}
double rad = Math.acos(cos);
if (ax < 0) {
rad = 2 * Math.PI - rad;
}
int uiRot = getWindowManager().getDefaultDisplay().getRotation();
double uiRad = Math.PI / 2 * uiRot;
rad -= uiRad;
/**
* 当加速度的差值大于指定的阈值,认为这是一个摇晃
*/
if (rad >= 90 || rad < -90)
{
deal.showToast(myContext, "旋转角度为:"+rad);
}
}
}
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import com.huawei.voice.R;
import com.huawei.voice.util.Parameters;
import com.huawei.voice.util.ToastDeal;
/**
*
* 手机翻转事件处理 待测试
*
* @author mickey_hou
* @version 1.0, 2012-5-17
* @since Tiantian
*/
public class TurningDealActivity extends Activity implements SensorEventListener
{
private SensorManager sensorManager;
private ToastDeal deal = new ToastDeal();
private long mLastUpdateTime;
//private float mLastX, mLastY, mLastZ;
private Context myContext;
public int shakeThreshold = 1500;
@Override
public void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setContentView(R.layout.main);
myContext = TurningDealActivity.this;
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
}
@Override
protected void onResume()
{
super.onResume();
sensorManager.registerListener(this,sensorManager.getDefaultSensor(
Sensor.TYPE_ACCELEROMETER),//TYPE_ACCELEROMETER 传感器类型 :加速度
SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onStop()
{
sensorManager.unregisterListener(this);
super.onStop();
}
public void onAccuracyChanged(Sensor sensor, int accuracy)
{
}
public void onSensorChanged(SensorEvent event)
{
long currentTime = System.currentTimeMillis();
long diffTime = currentTime - mLastUpdateTime;
if (diffTime < Parameters.UPDATE_INTERVAL)
{
return;
}
this.mLastUpdateTime = currentTime;
/*
* 旋转角度测试
*/
float[] values = event.values;
float ax = values[0];
float ay = values[1];
double g = Math.sqrt(ax * ax + ay * ay);
double cos = ay / g;
if (cos > 1) {
cos = 1;
} else if (cos < -1) {
cos = -1;
}
double rad = Math.acos(cos);
if (ax < 0) {
rad = 2 * Math.PI - rad;
}
int uiRot = getWindowManager().getDefaultDisplay().getRotation();
double uiRad = Math.PI / 2 * uiRot;
rad -= uiRad;
/**
* 当加速度的差值大于指定的阈值,认为这是一个摇晃
*/
if (rad >= 90 || rad < -90)
{
deal.showToast(myContext, "旋转角度为:"+rad);
}
}
}
发表评论
-
IMF简介-2
2013-07-09 17:56 917InputManager 由UI控件(View,TextVie ... -
IMF简介-1
2013-07-09 17:51 827Input Method Framework 目录 ... -
输入法 总结-3
2013-07-08 15:02 863public class MainActivity exten ... -
输入法 总结-4
2013-07-04 17:29 946public class InputActivity exte ... -
输入法 总结-3
2013-07-04 17:28 868public class InputApplication e ... -
输入法 总结-2
2013-07-04 17:23 789openwnn_pref_ja.xml <?xml v ... -
输入法 总结-2
2013-07-04 17:21 13openwnn_pref_ja.xml <?xml v ... -
输入法 总结-1
2013-07-04 17:19 808<application android ... -
Android快捷键
2013-03-15 14:39 851Home键(小房子键) 在 ... -
如何通过wifi调试android程序
2013-02-27 15:48 782android手机居然可以通过wifi进行程序的调试,太好了, ... -
Please ensure that adb is correctly located at 'D:\android-sdk-windows\platform-
2013-02-27 14:27 1674adt 出现ADB server didn't ACK, fa ... -
Android AsyncTask
2013-02-19 09:35 1142AsyncTask是抽象类,子类 ... -
Android ViewPager 左右滑动2-1
2013-01-29 10:12 1525public class PagerActivity exte ... -
Android ViewPager 左右滑动-3
2013-01-29 10:10 1115<?xml version="1.0" ... -
Android ViewPager 左右滑动-2
2013-01-29 10:10 1494/*** * 选中效果 */ pu ... -
Android ViewPager 左右滑动-1
2013-01-29 10:09 1396Store extends ActivityGroup imp ... -
Android 下载
2013-01-27 00:59 926下载apk程序代码 protected File downLo ... -
Android SDCard操作-3
2013-01-26 18:31 896public static Intent getVid ... -
Android SDCard操作-2
2013-01-26 18:30 1133/** * 判断该应用在手机中的安装情况 ... -
Android SDCard操作-1
2013-01-26 18:27 1069private static int INSTALLED = ...
相关推荐
Turning an iPhone on and off should be easy— and it is. However, the iPhone can be in one of four states: on, off, sleep, or airplane mode. If all of this sounds more confusing than just turn- ing ...
为了提供更精确的指引,可以加上具体的信息,比如 “Turn right at the second turning.” 表示在第二个路口右转。另外,还会用到 “It is on the right / left.” 来描述目的地在哪个方向。 理解地图和使用方位...
An Android device, such as a smart phone or tablet, is also helpful, but not necessary. Table of Contents Chapter 1. Wrapping Your Head Around Glass Part I The Mirror API Chapter 2. The Google App ...
具体到本单元,一些重要的词汇有邮局(post office)、警察局(police station)、酒店(hotel)、餐厅(restaurant)、银行(bank)、医院(hospital)、公用电话(pay phone)、邻里(neighborhood)以及一系列...
22. "On receiving a phone call from his wife saying she had a fall," "saying"是现在分词,作定语修饰"call",表示电话内容。 23. "Seeing is believing." 这是一句谚语,意为眼见为实。 24. "It’s amazing ...
题一:Now that we ____ all the money, it’s no use turning on me and saying it’s all my fault. 此句中,"Now that"引导的条件状语从句通常与现在完成时态连用,表示过去的动作对现在的影响,所以正确答案是C....
- 第四章"Turning On the Lights"会介绍OpenGL ES中的光照模型和渲染技术,可能包括如何在3D场景中添加光源、材质、着色、环境光、漫反射和镜面反射等概念。 - 第五章"Textures"将着重于纹理映射技术,讲解如何将...
- **表示变化中的状态**:常见于动词如get, grow, become, turn, run, go, begin等,如"The leaves are turning red."(叶子正在变红)和"It's getting warmer and warmer."(天气越来越暖和)。 - **与always, ...
print("Error turning off torch: \(error.localizedDescription)") } } } ``` ```objective-c - (void)toggleTorch { AVCaptureDevice *device = self.captureDevice; AVCaptureDevice TorchMode; if (device...
#### 回头率(huitoulv)— head-turning rate **定义与解释:** 回头率(huitoulv),直译为“回头查看的频率”,这个词语用来形容一个人或物品在公共场所能够引起他人注意的能力。通常用于形容人的外貌吸引力,...
- 修正了 `turning + turned` 事件顺序问题 - 修正了在错误位置添加页面的问题 #### 四、使用方法 - **HTML 结构**: - turn.js 需要在 DOM 中指定一个容器元素来承载所有页面。 - 可通过三种方式添加页面到翻...
Turning (现在分词或动名词) - D. To turn (不定式) 正确答案是 **A. Turn**。这是一个祈使句,用于表示命令或请求,因此需要使用动词原形。 #### 2. 介词 in/on/at 的用法 - **句子结构**: “Our class will ...
- **turn** → **turning** - **touch** → **touching** - **row** → **rowing** - **stand** → **standing** - **open** → **opening** - **wait** → **waiting** - **shout** → **shouting** - **laugh** →...
This volume efficiently recounts the story of microcredit, then discusses Social Business, organizations designed to help people while turning profits. French food giant Danone's partnership to ...
Starting Up the cp by turning power on /13 Starting Up the Cp by Warm Reset 14 Communication Process15/ Low-Power Sleep Mode-16 Chapter 4 Coprocessor Registers 17 Register Addresses 17 Register ...