Skip to content

Instantly share code, notes, and snippets.

@MiraLak
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiraLak/924090ad709098284d6c to your computer and use it in GitHub Desktop.
Save MiraLak/924090ad709098284d6c to your computer and use it in GitHub Desktop.
Android app: Basic accelerometer
public class StartActivity extends ActionBarActivity {
public static final String URL = "restURL"; //Default url to post data
private EditText restURL;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// show first layout called activity_start.xml
setContentView(R.layout.activity_start);
// get url value from field 'editURL'
restURL = (EditText) findViewById(R.id.editURL);
// declare start button
Button myButton = (Button) findViewById(R.id.button_start);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
//after click on button we switch to AccelerometerActivity class
//with parameter restURL
intent.setClass(StartActivity.this, AccelerometerActivity.class);
intent.putExtra(URL, restURL.getText().toString());
startActivity(intent);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment