Skip to content

Instantly share code, notes, and snippets.

@MiraLak MiraLak/StartActivity.java Secret
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.