Display GEO location : Location « Hardware « Android






Display GEO location

 



package app.test;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Test extends Activity {
  private EditText lat;
  private EditText lon;
  
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    
    Button btn=(Button)findViewById(R.id.map);
    lat=(EditText)findViewById(R.id.lat);
    lon=(EditText)findViewById(R.id.lon);
    
    btn.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
        String _lat=lat.getText().toString();
        String _lon=lon.getText().toString();
        Uri uri=Uri.parse("geo:"+_lat+","+_lon);
        
        startActivity(new Intent(Intent.ACTION_VIEW, uri));
      }
    });
  }
}

//main.cml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
  <TableLayout
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:stretchColumns="1,2"
  >
    <TableRow>
      <TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingLeft="2dip"
        android:paddingRight="4dip"
        android:text="Location:"
      />
      <EditText android:id="@+id/lat"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:cursorVisible="true"
        android:editable="true"
        android:singleLine="true"
        android:layout_weight="1"
      />
      <EditText android:id="@+id/lon"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:cursorVisible="true"
        android:editable="true"
        android:singleLine="true"
        android:layout_weight="1"
      />
    </TableRow>
  </TableLayout>
  <Button android:id="@+id/map"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:text="Show Me!"
  />
</LinearLayout>

   
  








Related examples in the same category

1.Location service and LocationManager
2.Location service
3.Using LocationManager
4.My location
5.Using location service for the weather
6.Using Intent to go to a geo location
7.Location based service
8.My location and Google Map
9.Custom Location Overlay
10.Get my location
11.Geo location and Google Map
12.Location Tracking
13.A light pool of objects that can be resused to avoid allocation.
14.extends android.location.Location
15.Geo Location Util
16.C:\Java_Dev\WEB\dev\android\weatherforecastsystem-read-only\com\hci\pwf\LocationUtil.java
17.upload Data with Geo location
18.Copy a file from one location to another.
19.LocationManager.GPS_PROVIDER
20.Location util