###前提・実現したいこと
Android WearとAndroidのタブレット端末を用いてAndroid Wearで取得した加速度センサの情報をスマートフォンに送信するシステムを作成しております。
作成している実機は以下のとおりとなります。
Android Wear : SmartWatch3(sony)
Androidタブレット : Nexus7(2012)
###発生している問題・エラーメッセージ
スマートフォンの加速度を取得するプログラムは以下のとおり作成することができております。
これに手を加えればWear側の加速度所取得してスマートフォンに送信することができると考えたのですが,うまく実装することができておりません。
###該当のソースコード
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.hardware.SensorManager;
import android.hardware.SensorListener;
public class SubActivity extends Activity implements SensorListener {
final String tag = "IBMEyes"; SensorManager sm = null; TextView xViewA = null; TextView yViewA = null; TextView zViewA = null; TextView xViewO = null; TextView yViewO = null; TextView zViewO = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sm = (SensorManager) getSystemService(SENSOR_SERVICE); setContentView(R.layout.sensing); xViewA = (TextView) findViewById(R.id.xbox); yViewA = (TextView) findViewById(R.id.ybox); zViewA = (TextView) findViewById(R.id.zbox); xViewO = (TextView) findViewById(R.id.xboxo); yViewO = (TextView) findViewById(R.id.yboxo); zViewO = (TextView) findViewById(R.id.zboxo); } public void onSensorChanged(int sensor, float[] values) { synchronized (this) { Log.d(tag, "onSensorChanged: " + sensor + ", x: " + values[0] + ", y: " + values[1] + ", z: " + values[2]); if (sensor == SensorManager.SENSOR_ORIENTATION) { xViewO.setText("Orientation X: " + values[0]); yViewO.setText("Orientation Y: " + values[1]); zViewO.setText("Orientation Z: " + values[2]); } if (sensor == SensorManager.SENSOR_ACCELEROMETER) { xViewA.setText("Accel X: " + values[0]); yViewA.setText("Accel Y: " + values[1]); zViewA.setText("Accel Z: " + values[2]); } } } public void onAccuracyChanged(int sensor, int accuracy) { Log.d(tag,"onAccuracyChanged: " + sensor + ", accuracy: " + accuracy); } @Override protected void onResume() { super.onResume(); sm.registerListener(this, SensorManager.SENSOR_ORIENTATION | SensorManager.SENSOR_ACCELEROMETER, SensorManager.SENSOR_DELAY_NORMAL); } @Override protected void onStop() { sm.unregisterListener(this); super.onStop(); }
}
###補足情報(言語/FW/ツール等のバージョンなど)
Android Wearに関する情報が少なく,また私の技術力不足のため言葉足らずとなってしまいましたが,どうぞよろしくお願い致します。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。