-
-
Save MiraLak/924090ad709098284d6c to your computer and use it in GitHub Desktop.
Android app: Basic accelerometer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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