1 package com.android.pmc; 2 3 import android.app.Activity; 4 import android.content.Intent; 5 import android.os.Bundle; 6 import android.widget.EditText; 7 8 public class SettingActivity extends Activity { 9 10 EditText mServerIP; 11 EditText mServerPort; 12 EditText mInterval; 13 EditText mIperfBandwidth; 14 EditText mIperfLogfile; 15 16 @Override onCreate(Bundle savedInstanceState)17 protected void onCreate(Bundle savedInstanceState) { 18 super.onCreate(savedInstanceState); 19 setContentView(R.layout.activity_setting); 20 mServerIP = (EditText) findViewById(R.id.server_iptext); 21 mServerPort = (EditText) findViewById(R.id.server_porttext); 22 mInterval = (EditText) findViewById(R.id.intervaltext); 23 mIperfBandwidth = (EditText) findViewById(R.id.iperf_bandwidthtext); 24 mIperfLogfile = (EditText) findViewById(R.id.iperf_logfiletext); 25 // Populate the fields with the current values passed from PMCMainActivity. 26 Intent intent = this.getIntent(); 27 mServerIP.setText(intent.getStringExtra(PMCMainActivity.SETTING_SERVER_IP_KEY)); 28 mServerPort.setText(intent.getStringExtra(PMCMainActivity.SETTING_SERVER_PORT_KEY)); 29 mInterval.setText(intent.getStringExtra(PMCMainActivity.SETTING_INTERVAL_KEY)); 30 mIperfBandwidth.setText(intent.getStringExtra(PMCMainActivity.SETTING_IPERF_BANDWIDTH_KEY)); 31 mIperfLogfile.setText(intent.getStringExtra(PMCMainActivity.SETTING_IPERF_LOGFILE_KEY)); 32 } 33 34 @Override onBackPressed()35 public void onBackPressed() { 36 Intent intent = new Intent(); 37 intent.putExtra(PMCMainActivity.SETTING_SERVER_IP_KEY, mServerIP.getText().toString()); 38 intent.putExtra(PMCMainActivity.SETTING_SERVER_PORT_KEY, mServerPort.getText().toString()); 39 intent.putExtra(PMCMainActivity.SETTING_INTERVAL_KEY, mInterval.getText().toString()); 40 intent.putExtra(PMCMainActivity.SETTING_IPERF_BANDWIDTH_KEY, 41 mIperfBandwidth.getText().toString()); 42 intent.putExtra(PMCMainActivity.SETTING_IPERF_LOGFILE_KEY, 43 mIperfLogfile.getText().toString()); 44 setResult(0, intent); //The data you want to send back 45 finish(); 46 } 47 } 48