<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Accelerometer on Micha Kops&#39; Tech Notes</title>
    <link>https://www.hascode.com/tags/accelerometer/</link>
    <description>Recent content in Accelerometer on Micha Kops&#39; Tech Notes</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2010 - 2025 Micha Kops. #e9d956c0c0154a221ad83c925346a8fa0e72f866</copyright>
    <lastBuildDate>Wed, 04 Aug 2010 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://www.hascode.com/tags/accelerometer/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to create an Android App using Google’s App Inventor</title>
      <link>https://www.hascode.com/how-to-create-an-android-app-using-googles-app-inventor/</link>
      <pubDate>Wed, 04 Aug 2010 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/how-to-create-an-android-app-using-googles-app-inventor/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Today we’re going to take a look at Google’s App Inventor feature that offers programming-novices a nice possibility to enter the fabulous world of Android App programming without deeper knowledge of the API or complex SDK installations.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;So lets build some stuff ..&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;http://java.oracle.com&#34;&gt;Java 6 JDK&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;http://appinventor.googlelabs.com/learn/setup/index.html&#34;&gt;App Inventors Extras Software&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A Google App Inventor Beta Account – request one &lt;a href=&#34;https://services.google.com/fb/forms/appinventorinterest/&#34;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_what_we_are_going_to_build&#34;&gt;What we are going to build&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;We are building a simple GUI with a Textbox and a button&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A click on the button starts an event that queries the acceleration sensor for coordinates&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the sensor is active and enabled then the coordinates are displayed in the text box&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Sensor Fun: Using the accelerometer on Android</title>
      <link>https://www.hascode.com/sensor-fun-using-the-accelerometer-on-android/</link>
      <pubDate>Tue, 27 Apr 2010 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/sensor-fun-using-the-accelerometer-on-android/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Here is an example on how to use the accelerometer in your Android application. If you want to simulate the acceleration on the emulator I highly recommend the &lt;em&gt;Sensor Simulator&lt;/em&gt; on the &lt;a href=&#34;http://code.google.com/p/openintents/wiki/SensorSimulator&#34;&gt;OpenIntents website&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;The following example app displays the coordinates received by the sensor.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_the_acceleration_app&#34;&gt;The Acceleration App&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The activity – &lt;em&gt;AccelerationActivity.java&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;package com.hascode.android;

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 android.widget.TextView;

public class AccellerationActivity extends Activity {
	private TextView result;
	private SensorManager sensorManager;
	private Sensor sensor;
	private float x, y, z;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
		sensor = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);

		result = (TextView) findViewById(R.id.result);
		result.setText(&amp;#34;No result yet&amp;#34;);
	}

	private void refreshDisplay() {
		String output = String
				.format(&amp;#34;x is: %f / y is: %f / z is: %f&amp;#34;, x, y, z);
		result.setText(output);
	}

	@Override
	protected void onResume() {
		super.onResume();
		sensorManager.registerListener(accelerationListener, sensor,
				SensorManager.SENSOR_DELAY_GAME);
	}

	@Override
	protected void onStop() {
		sensorManager.unregisterListener(accelerationListener);
		super.onStop();
	}

	private SensorEventListener accelerationListener = new SensorEventListener() {
		@Override
		public void onAccuracyChanged(Sensor sensor, int acc) {
		}

		@Override
		public void onSensorChanged(SensorEvent event) {
			x = event.values[0];
			y = event.values[1];
			z = event.values[2];
			refreshDisplay();
		}

	};
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
