- Forum posts: 2
Apr 21, 2016, 5:54:17 PM via Website
Apr 21, 2016 5:54:17 PM via Website
Hi everyone, i'm new here (sorry for my bad english). I'm facing a problem when trying to use accelerometer sensor in an app (based on the MapsActivity) developed by me. For the moment this app only let the user move to certain places and add a marker by tapping on displayed buttons. I would like to make this app moving the marker by simply moving the device (using accelerometer). I used this code in addition to the positioning management code:
private SensorManager mSensorManager;
private Sensor sensor;
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
}
For the moment it sould only show up a toast message to test it, but it doesn't work. How could i solve this problem?
Thanks in advance.
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.