Hello:
I am trying to get the openintents sensor simulator working. I followed the
instructions from http://code.google.com/p/openintents/wiki/SensorSimulator.
I set the conection instruction
SensorManagerSimulator.connectSimulator();
as part of the menu as in the example file OpenGLSensors.java, but every
time I select the option to connect the Activity exits with no error. I
have checked the websites tutorial to see what I am missing but can't find
it. I also looked at the OpenGL example (which does work on the emulator)
to look for what I am missing, but no luck.
Any help is appreciated
The code is:
package com.fitandroid.gravityapp;
import org.openintents.OpenIntents;
import org.openintents.hardware.SensorManagerSimulator;
import org.openintents.provider.Hardware;
import android.app.Activity;
import android.content.Intent;
import android.hardware.SensorListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
public class GravityTest extends Activity implements SensorListener{
SensorManager mSensorManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
//mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
//mSensorManager.registerListener(this,
SensorManager.SENSOR_ACCELEROMETER);
OpenIntents.requiresOpenIntents(this);
Hardware.mContentResolver = getContentResolver();
mSensorManager = (SensorManager) new SensorManagerSimulator(
(SensorManager)
getSystemService( SENSOR_SERVICE) );
Intent intent = new Intent(Intent.ACTION_VIEW,
Hardware.Preferences.CONTENT_URI);
startActivity(intent);
mSensorManager.unregisterListener(this);
mSensorManager.registerListener( this,
SensorManager.SENSOR_ACCELEROMETER );
setContentView(R.layout.main);
EditText view = (EditText) findViewById(R.id.output);
float acelerometer = 0.0F;
view.setText("Accelerometer: " + acelerometer);
}
@Override
protected void onResume() {
super.onResume();
//SensorReactor reactor = new SensorReactor();
mSensorManager.registerListener(this
, SensorManager.SENSOR_ACCELEROMETER );
}
@Override
protected void onStop() {
mSensorManager.unregisterListener(this);
super.onStop();
}
public void onAccuracyChanged(int sensor, int accuracy){
setContentView(R.layout.main);
EditText view = (EditText) findViewById(R.id.output);
view.setText("jsjdlfj");
}
public void onSensorChanged(int sensor, float[] values){
if( sensor == SensorManager.SENSOR_ACCELEROMETER){
setContentView(R.layout.main);
EditText view = (EditText) findViewById(R.id.output);
float acelerometer = values[0];
view.setText("" + acelerometer);
}
}
private static final int MENU_CONNECT = Menu.FIRST + 100;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu);
menu.add(0, MENU_CONNECT ,0, R.string.connect);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
// TODO Auto-generated method stub
super.onMenuItemSelected(featureId, item);
switch( item.getItemId() ){
case MENU_CONNECT:
String str = "";
SensorManagerSimulator.connectSimulator();
EditText view = (EditText) findViewById(R.id.output);
view.setText("Conected" + str);
break;
}
return true;
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---