Example usage for android.content Intent getDoubleArrayExtra

List of usage examples for android.content Intent getDoubleArrayExtra

Introduction

In this page you can find the example usage for android.content Intent getDoubleArrayExtra.

Prototype

public double[] getDoubleArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static double[] getDoubleArrayExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getDoubleArrayExtra(name);
}

From source file:org.iransoil.collect.android.activities.GeoPointMapActivitySdk7.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/* ww w .j av  a  2 s  .com*/

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geopoint_layout_sdk7);

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mGeoPoint = new GeoPoint((int) (location[0] * 1E6), (int) (location[1] * 1E6));
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
    }

    /**
     * Add the MapView dynamically to the placeholding frame so as to not
     * incur the wrath of Android Lint...
     */
    FrameLayout frame = (FrameLayout) findViewById(R.id.mapview_placeholder);
    String apiKey = "017Xo9E6R7WmcCITvo-lU2V0ERblKPqCcguwxSQ";
    // String apiKey = "0wsgFhRvVBLVpgaFzmwaYuqfU898z_2YtlKSlkg";
    mMapView = new MapView(this, apiKey);
    mMapView.setClickable(true);
    mMapView.setId(R.id.mapview);
    LayoutParams p = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    frame.addView(mMapView, p);

    mCancelLocation = (Button) findViewById(R.id.cancel_location);
    mCancelLocation.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel");
            finish();
        }
    });

    mMapController = mMapView.getController();
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mMapView.setBuiltInZoomControls(true);
    mMapView.setSatellite(false);
    mMapController.setZoom(16);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        if (ActivityCompat.checkSelfPermission(this,
                Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(this,
                        Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mLocationOverlay = new MyLocationOverlay(this, mMapView);
    mMapView.getOverlays().add(mLocationOverlay);

    if (mCaptureLocation) {
        mLocationStatus = (TextView) findViewById(R.id.location_status);
        mAcceptLocation = (Button) findViewById(R.id.accept_location);
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
            }
        });

    } else {

        mGeoPointOverlay = new Marker(mGeoPoint);
        mMapView.getOverlays().add(mGeoPointOverlay);

        ((Button) findViewById(R.id.accept_location)).setVisibility(View.GONE);
        ((TextView) findViewById(R.id.location_status)).setVisibility(View.GONE);
        mShowLocation = ((Button) findViewById(R.id.show_location));
        mShowLocation.setVisibility(View.VISIBLE);
        mShowLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
                mMapController.animateTo(mGeoPoint);
            }
        });

    }

    if (mGeoPoint != null) {
        mMapController.animateTo(mGeoPoint);
    }
}

From source file:org.koboc.collect.android.activities.GeoPointMapNotDraggableActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/*from  w w w.  java2  s .co m*/

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    try {
        setContentView(R.layout.geopoint_layout);
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
        mRefreshLocation = mCaptureLocation;
    }

    /* Set up the map and the marker */
    mMarkerOption = new MarkerOptions();

    mLocationStatus = (TextView) findViewById(R.id.location_status);

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mLocationStatus.setVisibility(View.GONE);
        mMarkerOption.position(mLatLng);
        mRefreshLocation = false; // just show this position; don't change it...
        mZoomed = true;
    }

    mCancelLocation = (Button) findViewById(R.id.cancel_location);
    mCancelLocation.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel");
            finish();
        }
    });

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mAcceptLocation = (Button) findViewById(R.id.accept_location);
    if (mCaptureLocation) {
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
            }
        });
    } else {
        mAcceptLocation.setVisibility(View.GONE);
    }

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    if (mCaptureLocation) {
        mReloadLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mRefreshLocation = true;
                mReloadLocation.setVisibility(View.GONE);
                mLocationStatus.setVisibility(View.VISIBLE);
                if (mGPSOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            GeoPointMapNotDraggableActivity.this);
                }
                if (mNetworkOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            GeoPointMapNotDraggableActivity.this);
                }
            }

        });
        mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE);
    } else {
        mReloadLocation.setVisibility(View.GONE);
    }

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    mShowLocation.setVisibility(View.VISIBLE);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
        }
    });

    // not clickable until we have a marker set....
    mShowLocation.setClickable(false);
}

From source file:org.odk.collect.android.activities.GeoPointMapNotDraggableActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }//from   w  w w . j  av  a 2 s .c om

    try {
        setContentView(R.layout.geopoint_layout);
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
        mRefreshLocation = mCaptureLocation;
    }

    /* Set up the map and the marker */
    mMarkerOption = new MarkerOptions();

    mLocationStatus = (TextView) findViewById(R.id.location_status);

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mLocationStatus.setVisibility(View.GONE);
        mMarkerOption.position(mLatLng);
        mRefreshLocation = false; // just show this position; don't change it...
        mZoomed = true;
    }

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mAcceptLocation = (Button) findViewById(R.id.accept_location);
    if (mCaptureLocation) {
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
            }
        });
    } else {
        mAcceptLocation.setVisibility(View.GONE);
    }

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    if (mCaptureLocation) {
        mReloadLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mRefreshLocation = true;
                mReloadLocation.setVisibility(View.GONE);
                mLocationStatus.setVisibility(View.VISIBLE);
                if (mGPSOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            GeoPointMapNotDraggableActivity.this);
                }
                if (mNetworkOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            GeoPointMapNotDraggableActivity.this);
                }
            }

        });
        mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE);
    } else {
        mReloadLocation.setVisibility(View.GONE);
    }

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    mShowLocation.setVisibility(View.VISIBLE);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
        }
    });

    // not clickable until we have a marker set....
    mShowLocation.setClickable(false);

    // Menu Layer Toggle
    mLayers = ((Button) findViewById(R.id.layer_menu));
    mLayers.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mHelper.showLayersDialog();
        }
    });

}

From source file:cd.education.data.collector.android.activities.GeoPointMapActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }//w w w . java 2  s.com

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geopoint_layout);

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
        mRefreshLocation = mCaptureLocation;
    }

    /* Set up the map and the marker */
    mMarkerOption = new MarkerOptions();
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.setOnMarkerDragListener(this);

    mLocationStatus = (TextView) findViewById(R.id.location_status);

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mLocationStatus.setVisibility(View.GONE);
        mMarkerOption.position(mLatLng);
        mMarker = mMap.addMarker(mMarkerOption);
        mRefreshLocation = false; // just show this position; don't change it...
        mMarker.setDraggable(mCaptureLocation);
        mZoomed = true;
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
    }

    mCancelLocation = (Button) findViewById(R.id.cancel_location);
    mCancelLocation.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel");
            finish();
        }
    });

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mAcceptLocation = (Button) findViewById(R.id.accept_location);
    if (mCaptureLocation) {
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
            }
        });
        mMap.setOnMapLongClickListener(this);
    } else {
        mAcceptLocation.setVisibility(View.GONE);
    }

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    if (mCaptureLocation) {
        mReloadLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mRefreshLocation = true;
                mReloadLocation.setVisibility(View.GONE);
                mLocationStatus.setVisibility(View.VISIBLE);
                if (mGPSOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
                if (mNetworkOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
            }

        });
        mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE);
    } else {
        mReloadLocation.setVisibility(View.GONE);
    }

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    mShowLocation.setVisibility(View.VISIBLE);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
        }
    });
    mShowLocation.setClickable(mMarker != null);

}

From source file:com.shearosario.tothepathandback.ClosestStationsActivity.java

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

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    context = this;
    activity = this;

    adView = (AdView) this.findViewById(R.id.adViewClosest);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);/*w w  w.ja  v a 2  s . co m*/

    if (intent.hasExtra("Manual")) {
        double[] manual = intent.getDoubleArrayExtra("Manual");
        origin = new LatLng(manual[0], manual[1]);
    } else if (intent.hasExtra("Current")) {
        double[] current = intent.getDoubleArrayExtra("Current");
        origin = new LatLng(current[0], current[1]);
    }

    double[] entranceMeasures = intent.getDoubleArrayExtra("closestSortMeasures");
    ArrayList<Entrance> closestEntrances = intent.getParcelableArrayListExtra("closestEntrances");

    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, R.layout.listitem, closestEntrances,
            entranceMeasures);
    //ListAdapter adapter = createListAdapter(allStationsSortDistance);
    ListView listview = (ListView) findViewById(R.id.ClosestStationsList);
    listview.setAdapter(adapter);
    //setListAdapter(adapter);

    final GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.addMarker(new MarkerOptions().title("Origin").position(origin));
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(origin, 13));
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_directions);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.directions_text);
    textView.setText(Html.fromHtml(
            "Directions, Nominatim Search Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Entrance item = (Entrance) parent.getItemAtPosition(position);

            gMap.clear();

            LatLngBounds bounds = new LatLngBounds.Builder().include(origin)
                    .include(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])).build();

            gMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

            gMap.addMarker(new MarkerOptions().title("Origin").position(origin));

            String stationName = null;
            for (int i = 0; i < MainActivity.getAllStations().size(); i++) {
                if (item.getStopid().equalsIgnoreCase(MainActivity.getAllStations().get(i).getStopID())) {
                    stationName = MainActivity.getAllStations().get(i).getStopName();
                    break;
                }
            }

            gMap.addMarker(new MarkerOptions()
                    // .title(item.getStationName())
                    .title(stationName)
                    .position(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])));

            Button button = (Button) findViewById(R.id.button_destination);
            button.setEnabled(true);
            // button.setText("Select " + item.getStationName());
            button.setText("Select " + stationName);

            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    /*
                     * To check if the phone is currently using a network connection. 
                     * Listens to broadcasts when the the device is or is not connected to 
                     * a network
                     */
                    ConnectivityManager cm = (ConnectivityManager) context
                            .getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
                    if (!isConnected) {
                        Toast.makeText(context, "No network connection", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    new DisplayDirectionsIntent(context, activity, origin, item);
                }
            });
        }
    });
}

From source file:com.mpower.clientcollection.activities.GeoPointMapActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/*from  w w  w  .j  av a  2 s . com*/

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geopoint_layout);

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
        mRefreshLocation = mCaptureLocation;
    }

    /* Set up the map and the marker */
    mMarkerOption = new MarkerOptions();
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.setOnMarkerDragListener(this);

    mLocationStatus = (TextView) findViewById(R.id.location_status);

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mLocationStatus.setVisibility(View.GONE);
        mMarkerOption.position(mLatLng);
        mMarker = mMap.addMarker(mMarkerOption);
        mRefreshLocation = false; // just show this position; don't change it...
        mMarker.setDraggable(mCaptureLocation);
        mZoomed = true;
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
    }

    mCancelLocation = (Button) findViewById(R.id.cancel_location);
    mCancelLocation.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation",
                    "cancel");
            finish();
        }
    });

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mAcceptLocation = (Button) findViewById(R.id.accept_location);
    if (mCaptureLocation) {
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation",
                        "OK");
                returnLocation();
            }
        });
        mMap.setOnMapLongClickListener(this);
    } else {
        mAcceptLocation.setVisibility(View.GONE);
    }

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    if (mCaptureLocation) {
        mReloadLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mRefreshLocation = true;
                mReloadLocation.setVisibility(View.GONE);
                mLocationStatus.setVisibility(View.VISIBLE);
                if (mGPSOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
                if (mNetworkOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
            }

        });
        mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE);
    } else {
        mReloadLocation.setVisibility(View.GONE);
    }

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    mShowLocation.setVisibility(View.VISIBLE);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ClientCollection.getInstance().getActivityLogger().logInstanceAction(this, "showLocation",
                    "onClick");
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
        }
    });
    mShowLocation.setClickable(mMarker != null);

}

From source file:org.koboc.collect.android.activities.GeoPointMapActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/* w  w w . j av a 2s  .c o m*/

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    try {
        setContentView(R.layout.geopoint_layout);
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    Intent intent = getIntent();

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }
        mCaptureLocation = !intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
        mRefreshLocation = mCaptureLocation;
    }

    /* Set up the map and the marker */
    mMarkerOption = new MarkerOptions();

    mLocationStatus = (TextView) findViewById(R.id.location_status);

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mLocationStatus.setVisibility(View.GONE);
        mMarkerOption.position(mLatLng);
        mRefreshLocation = false; // just show this position; don't change it...
        mZoomed = true;
    }

    mCancelLocation = (Button) findViewById(R.id.cancel_location);
    mCancelLocation.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "cancelLocation", "cancel");
            finish();
        }
    });

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // make sure we have a good location provider before continuing
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
        }
    }
    if (!mGPSOn && !mNetworkOn) {
        Toast.makeText(getBaseContext(), getString(R.string.provider_disabled_error), Toast.LENGTH_SHORT)
                .show();
        finish();
    }

    if (mGPSOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(GPS) null location");
        }
    }

    if (mNetworkOn) {
        Location loc = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (loc != null) {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) lat: " + loc.getLatitude() + " long: " + loc.getLongitude()
                    + " acc: " + loc.getAccuracy());
        } else {
            InfoLogger.geolog("GeoPointMapActivity: " + System.currentTimeMillis()
                    + " lastKnownLocation(Network) null location");
        }
    }

    mAcceptLocation = (Button) findViewById(R.id.accept_location);
    if (mCaptureLocation) {
        mAcceptLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
                returnLocation();
            }
        });
    } else {
        mAcceptLocation.setVisibility(View.GONE);
    }

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    if (mCaptureLocation) {
        mReloadLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mRefreshLocation = true;
                mReloadLocation.setVisibility(View.GONE);
                mLocationStatus.setVisibility(View.VISIBLE);
                if (mGPSOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
                if (mNetworkOn) {
                    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                            GeoPointMapActivity.this);
                }
            }

        });
        mReloadLocation.setVisibility(!mRefreshLocation ? View.VISIBLE : View.GONE);
    } else {
        mReloadLocation.setVisibility(View.GONE);
    }

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    mShowLocation.setVisibility(View.VISIBLE);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
        }
    });

    // not clickable until we have a marker set....
    mShowLocation.setClickable(false);
}

From source file:org.odk.collect.android.activities.GeoPointMapActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/*from   ww  w  .java  2s .  c  o m*/

    try {
        setContentView(R.layout.geopoint_layout);
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    if (mMap == null) {
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    mMap.setMyLocationEnabled(true);
    mMap.getUiSettings().setCompassEnabled(true);
    mMap.getUiSettings().setMyLocationButtonEnabled(false);
    mMap.getUiSettings().setZoomControlsEnabled(false);
    mMarkerOption = new MarkerOptions();
    mHelper = new MapHelper(this, mMap);

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mLocationStatus = (TextView) findViewById(R.id.location_status);
    mlocationInfo = (TextView) findViewById(R.id.location_info);

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mAcceptLocation = (Button) findViewById(R.id.accept_location);

    mAcceptLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
            returnLocation();
        }
    });

    mReloadLocation = (Button) findViewById(R.id.reload_location);
    mReloadLocation.setEnabled(false);
    mReloadLocation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMarker != null) {
                mMarker.remove();
            }
            mLatLng = null;
            mMarker = null;
            setClear = false;
            mLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
            mMarkerOption.position(mLatLng);
            if (mMarker == null) {
                mMarker = mMap.addMarker(mMarkerOption);
                if (draggable && !read_only) {
                    mMarker.setDraggable(true);
                }
            }
            mCaptureLocation = true;
            mIsDragged = false;
            zoomToPoint();
        }

    });

    // Focuses on marked location
    mShowLocation = ((Button) findViewById(R.id.show_location));
    //      mShowLocation.setClickable(false);
    mShowLocation.setEnabled(false);
    mShowLocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showZoomDialog();
        }
    });

    // Menu Layer Toggle
    mLayers = ((Button) findViewById(R.id.layer_menu));
    mLayers.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mHelper.showLayersDialog();
        }
    });
    zoomDialogView = getLayoutInflater().inflate(R.layout.geopoint_zoom_dialog, null);
    zoomLocationButton = (Button) zoomDialogView.findViewById(R.id.zoom_location);
    zoomLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomToLocation();
            zoomDialog.dismiss();
        }
    });

    zoomPointButton = (Button) zoomDialogView.findViewById(R.id.zoom_point);
    zoomPointButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomToPoint();
            zoomDialog.dismiss();
        }
    });

    clearPointButton = (Button) findViewById(R.id.clear);
    clearPointButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMarker != null) {
                mMarker.remove();
            }
            if (mLocation != null) {
                mReloadLocation.setEnabled(true);
                //               mLocationStatus.setVisibility(View.VISIBLE);
            }
            //            mReloadLocation.setEnabled(true);
            mlocationInfo.setVisibility(View.VISIBLE);
            mLocationStatus.setVisibility(View.VISIBLE);
            mLatLng = null;
            mMarker = null;
            setClear = true;
            mIsDragged = false;
            mCaptureLocation = false;
            draggable = intent_draggable;
            location_from_intent = false;
            overlayMyLocationLayers();
        }
    });

    Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoPointWidget.DRAGGABLE_ONLY)) {
            draggable = intent.getBooleanExtra(GeoPointWidget.DRAGGABLE_ONLY, false);
            intent_draggable = draggable;
            if (!intent_draggable) {
                // Not Draggable, set text for Map else leave as placement-map text
                mlocationInfo.setText(getString(R.string.geopoint_no_draggable_instruction));
            }
        }

        if (intent.hasExtra(GeoPointWidget.READ_ONLY)) {
            read_only = intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
            if (read_only) {
                mCaptureLocation = true;
                clearPointButton.setEnabled(false);
            }
        }

        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new LatLng(location[0], location[1]);
            mCaptureLocation = true;
            mReloadLocation.setEnabled(false);
            draggable = false; // If data loaded, must clear first
            location_from_intent = true;

        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }

    }

    /*Zoom only if there's a previous location*/
    if (mLatLng != null) {
        mlocationInfo.setVisibility(View.GONE);
        mLocationStatus.setVisibility(View.GONE);
        mShowLocation.setEnabled(true);
        mMarkerOption.position(mLatLng);
        mMarker = mMap.addMarker(mMarkerOption);
        mCaptureLocation = true;
        foundFirstLocation = true;
        mZoomed = true;
        zoomToPoint();
    }
}

From source file:org.odk.collect.android.activities.GeoPointOsmMapActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (savedInstanceState != null) {
        mLocationCount = savedInstanceState.getInt(LOCATION_COUNT);
    }/*  ww  w . j av  a2 s.  c  o m*/

    try {
        setContentView(R.layout.geopoint_osm_layout);
    } catch (NoClassDefFoundError e) {
        e.printStackTrace();
        Toast.makeText(getBaseContext(), getString(R.string.google_play_services_error_occured),
                Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    mMap = (MapView) findViewById(R.id.omap);
    mHelper = new MapHelper(this, mMap, GeoPointOsmMapActivity.this);
    mMap.setMultiTouchControls(true);
    mMap.setBuiltInZoomControls(true);
    mMarker = new Marker(mMap);
    mMarker.setIcon(getResources().getDrawable(R.drawable.ic_place_black_36dp));
    mMyLocationOverlay = new MyLocationNewOverlay(this, mMap);

    handler.postDelayed(new Runnable() {
        public void run() {
            GeoPoint point = new GeoPoint(34.08145, -39.85007);
            mMap.getController().setZoom(4);
            mMap.getController().setCenter(point);
        }
    }, 100);

    mLocationAccuracy = GeoPointWidget.DEFAULT_LOCATION_ACCURACY;
    mLocationStatus = (TextView) findViewById(R.id.location_status);
    mlocationInfo = (TextView) findViewById(R.id.location_info);

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mSaveLocationButton = (Button) findViewById(R.id.accept_location);
    mSaveLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "acceptLocation", "OK");
            returnLocation();
        }
    });

    mReloadLocationButton = (Button) findViewById(R.id.reload_location);
    mReloadLocationButton.setEnabled(false);
    mReloadLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMap.getOverlays().add(mMarker);
            setClear = false;
            mLatLng = new GeoPoint(mLocation.getLatitude(), mLocation.getLongitude());
            mMarker.setPosition(mLatLng);
            mCaptureLocation = true;
            mIsDragged = false;
            zoomToPoint();
        }

    });

    // Focuses on marked location
    mShowLocationButton = ((Button) findViewById(R.id.show_location));
    mShowLocationButton.setVisibility(View.VISIBLE);
    mShowLocationButton.setEnabled(false);
    mShowLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Collect.getInstance().getActivityLogger().logInstanceAction(this, "showLocation", "onClick");
            showZoomDialog();
        }
    });

    // not clickable until we have a marker set....
    mShowLocationButton.setClickable(false);

    // Menu Layer Toggle
    mLayersButton = ((Button) findViewById(R.id.layer_menu));
    mLayersButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mHelper.showLayersDialog();

        }
    });

    zoomDialogView = getLayoutInflater().inflate(R.layout.geopoint_zoom_dialog, null);

    zoomLocationButton = (Button) zoomDialogView.findViewById(R.id.zoom_location);
    zoomLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            zoomToLocation();
            mMap.invalidate();
            zoomDialog.dismiss();
        }
    });

    zoomPointButton = (Button) zoomDialogView.findViewById(R.id.zoom_point);
    zoomPointButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomToPoint();
            mMap.invalidate();
            zoomDialog.dismiss();
        }
    });

    clearPointButton = (Button) findViewById(R.id.clear);
    clearPointButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMap.getOverlays().remove(mMarker);
            mMarker.remove(mMap);
            if (mLocation != null) {
                mReloadLocationButton.setEnabled(true);
                //               mLocationStatus.setVisibility(View.VISIBLE);
            }
            mLocationStatus.setVisibility(View.VISIBLE);
            mMap.getOverlays().remove(mMarker);
            mMarker.remove(mMap);
            setClear = true;
            mIsDragged = false;
            mCaptureLocation = false;
            draggable = intent_draggable;
            location_from_intent = false;
            overlayMyLocationLayers();
            mMap.invalidate();
        }
    });

    Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {

        if (intent.hasExtra(GeoPointWidget.DRAGGABLE_ONLY)) {
            draggable = intent.getBooleanExtra(GeoPointWidget.DRAGGABLE_ONLY, false);
            intent_draggable = draggable;
            if (!intent_draggable) {
                // Not Draggable, set text for Map else leave as placement-map text
                mlocationInfo.setText(getString(R.string.geopoint_no_draggable_instruction));
            }
        }

        if (intent.hasExtra(GeoPointWidget.READ_ONLY)) {
            read_only = intent.getBooleanExtra(GeoPointWidget.READ_ONLY, false);
            if (read_only) {
                mCaptureLocation = true;
                clearPointButton.setEnabled(false);
            }
        }

        if (intent.hasExtra(GeoPointWidget.LOCATION)) {
            double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
            mLatLng = new GeoPoint(location[0], location[1]);
            mReloadLocationButton.setEnabled(false);
            mCaptureLocation = true;
            mIsDragged = true;
            draggable = false; // If data loaded, must clear first
            location_from_intent = true;

        }
        if (intent.hasExtra(GeoPointWidget.ACCURACY_THRESHOLD)) {
            mLocationAccuracy = intent.getDoubleExtra(GeoPointWidget.ACCURACY_THRESHOLD,
                    GeoPointWidget.DEFAULT_LOCATION_ACCURACY);
        }

    }

    if (mLatLng != null) {
        mMarker.setPosition(mLatLng);
        mMap.getOverlays().add(mMarker);
        mMap.invalidate();
        mCaptureLocation = true;
        foundFirstLocation = true;
        mZoomed = true;
        zoomToPoint();
    }

}