Android Open Source - GetLocation Main Activity






From Project

Back to project page GetLocation.

License

The source code is released under:

GNU General Public License

If you think the Android project GetLocation listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package my.app.location;
/*w  w  w.  j av  a2 s.c o  m*/
import my.app.location.utils.Location;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

  private EditText etInput;
  private TextView tvOutput;
  private Button bSearch;

  private final int REQUEST_CODE = 1;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    initView();
  }

  private void initView() {
    etInput = (EditText) findViewById(R.id.etInput);
    tvOutput = (TextView) findViewById(R.id.tvOutput);
    bSearch = (Button) findViewById(R.id.bSearch);
    setListener();
  }

  private void setListener() {
    bSearch.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        String input = etInput.getText().toString();
        Intent intent = new Intent(MainActivity.this, MapActivity.class);
        intent.putExtra("input", input);
        startActivityForResult(intent, REQUEST_CODE);
      }
    });
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case (REQUEST_CODE): {
      if (resultCode == Activity.RESULT_OK) {
        String result = data.getStringExtra(MapActivity.RESULT);
        tvOutput.setText(result);
      }
      break;
    }
    }
  }

}




Java Source Code List

my.app.location.MainActivity.java
my.app.location.MapActivity.java
my.app.location.utils.Constants.java
my.app.location.utils.JsonParser.java
my.app.location.utils.Location.java