Example usage for android.content Intent getDoubleExtra

List of usage examples for android.content Intent getDoubleExtra

Introduction

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

Prototype

public double getDoubleExtra(String name, double defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static double getDoubleExtra(Intent intent, String name, double defaultValue) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return defaultValue;
    return intent.getDoubleExtra(name, defaultValue);
}

From source file:com.geekandroid.sdk.sample.RouteActivity.java

/**
 * ???/*from  w  w  w  .j  a v a 2 s. c  o  m*/
 */
private void initData() {
    Intent intent = getIntent();
    storeLatitude = intent.getDoubleExtra("storeLatitude", -1);
    storeLongitude = intent.getDoubleExtra("storeLongitude", -1);
    storeName = intent.getStringExtra("storeName");

}

From source file:com.example.yangseung.myapplication.SplitStreetViewPanoramaAndMapDemoActivity.java

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

    loadingLayout = (RelativeLayout) findViewById(R.id.loadingPanel);
    mainLayout = (LinearLayout) findViewById(R.id.map_container2);

    loadingLayout.setVisibility(View.VISIBLE);
    mainLayout.setVisibility(View.INVISIBLE);

    Intent intent = getIntent();
    clicked_latitude = intent.getDoubleExtra("clicked_latitude", 37.4958471);
    clicked_longtitude = intent.getDoubleExtra("clicked_longtitude", 127.033087);
    viewNumber = intent.getIntExtra("viewNumber", 0);
    SYDNEY = new LatLng(clicked_latitude, clicked_longtitude);
    SupportStreetViewPanoramaFragment streetViewPanoramaFragment = (SupportStreetViewPanoramaFragment) getSupportFragmentManager()
            .findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
        @Override//from   w ww .j a  v a  2s. c  o m
        public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {

            if (savedInstanceState == null) {
                panorama.setPosition(SYDNEY);
            }
        }
    });

    final CustomAdapter adapter = new CustomAdapter(getLayoutInflater(), 4, clicked_latitude,
            clicked_longtitude, this, viewNumber);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    loadingLayout.setVisibility(View.GONE);
    mainLayout.setVisibility(View.VISIBLE);

    Button btn1 = (Button) findViewById(R.id.button_upload);
    btn1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent intent = new Intent(SplitStreetViewPanoramaAndMapDemoActivity.this, Post.class);
            intent.putExtra("now", String.valueOf(pager.getCurrentItem()));
            intent.putExtra("clicked_latitude", clicked_latitude);
            intent.putExtra("clicked_longtitude", clicked_longtitude);
            startActivity(intent);
        }
    });

    Button btn2 = (Button) findViewById(R.id.button_evaluate);
    btn2.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent intent = new Intent(SplitStreetViewPanoramaAndMapDemoActivity.this, Evaluate.class);
            startActivity(intent);
        }
    });
}

From source file:com.swetha.easypark.GoogleDirectionsActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mapdirections);
    StrictMode.setThreadPolicy(/*from   w  w  w  .  j  a va2 s.c  o  m*/
            new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // StrictMode is most commonly used to catch accidental disk or network access on the application's main thread
                    .penaltyLog().build());
    Log.i("GoogleDirectionsActivity", "Inside Oncreate");

    Intent theIntent = getIntent();
    tolat = theIntent.getDoubleExtra(GetParkingLots.LATITUDE, Constants.doubleDefaultValue);
    tolng = theIntent.getDoubleExtra(GetParkingLots.LONGITUDE, Constants.doubleDefaultValue);

    toPosition = new LatLng(tolat, tolng);

    Log.i("GoogleDirectionsActivity",
            "After Setting tolat, tolng, toPosition" + tolat + "\n" + tolng + "\n" + toPosition);

    md = new GetDirections();
    Log.i("GoogleDirectionsActivity", "After calling GetDirctions constructor");

    FragmentManager fm = getSupportFragmentManager();
    Log.i("GoogleDirectionsActivity", "After creating fragmentManager" + fm);
    SupportMapFragment supportMapfragment = ((SupportMapFragment) fm.findFragmentById(R.id.drivingdirections));

    Log.i("GoogleDirectionsActivity", "After creating SupportMapFragment" + supportMapfragment);
    mMap = supportMapfragment.getMap();
    Log.i("GoogleDirectionsActivity", "After getting map");

    mMap.setMyLocationEnabled(true);
    Log.i("GoogleDirectionsActivity", "After  setMyLocationEnabled");
    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    Log.i("GoogleDirectionsActivity", "After  locationManager");
    Criteria criteria = new Criteria();

    // Getting the name of the provider that meets the criteria
    provider = locationManager.getBestProvider(criteria, true);

    if (provider != null && !provider.equals("")) {

        // Get the location from the given provider 
        location = locationManager.getLastKnownLocation(provider);

        locationManager.requestLocationUpdates(provider, 500, 1, GoogleDirectionsActivity.this);

        if (location != null) {

            fromlat = location.getLatitude();
            fromlng = location.getLongitude();
        }

        else {
            fromlat = GetParkingLots.latitude;
            fromlng = GetParkingLots.longitude;
        }

    } else {
        Toast.makeText(getBaseContext(), "No Provider Found", Toast.LENGTH_SHORT).show();
        finish();
    }
    Log.e("GoogleDirectionsActivity", "After  setting location");
    fromPosition = new LatLng(fromlat, fromlng);
    LatLng coordinates = new LatLng(fromlat, fromlng);
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinates, 16));

    mMap.addMarker(new MarkerOptions().position(fromPosition).title("Start"));
    mMap.addMarker(new MarkerOptions().position(toPosition).title("End"));

    Document doc = md.getDocument(fromPosition, toPosition, Constants.MODE_DRIVING);
    String duration = md.getDurationText(doc);

    tv_duration = (TextView) findViewById(R.id.tv_time);
    tv_duration.setText("Estimated driving time:" + duration);

    ArrayList<LatLng> directionPoint = md.getDirection(doc);

    PolylineOptions rectLine = new PolylineOptions().width(6).color(Color.RED);

    for (int i = 0; i < directionPoint.size(); i++) {
        rectLine.add(directionPoint.get(i));
    }

    mMap.addPolyline(rectLine);
}

From source file:org.immopoly.android.api.IS24ApiService.java

@Override
protected void onHandleIntent(Intent intent) {
    final ResultReceiver receiver = intent.getParcelableExtra(API_RECEIVER);
    double lat = intent.getDoubleExtra(LAT, 0.0);
    double lon = intent.getDoubleExtra(LNG, 0.0);
    Bundle b = new Bundle();
    Log.d(Const.LOG_TAG, "IS24 search started");
    try {/*from w  ww. j a v a  2s.  c  o  m*/
        receiver.send(STATUS_RUNNING, Bundle.EMPTY);
        final float[] radii = Const.SEARCH_RADII;
        // search for flats in radii[i]. finish if enough flats found (1 is enough in the last run)
        for (int i = 0; i < radii.length; i++) {
            int min = i == radii.length - 1 ? 1 : Const.SEARCH_MIN_RESULTS;
            Flats flats = loadFlats(lat, lon, radii[i], min, Const.SEARCH_MAX_RESULTS);
            if (flats != null) {
                Log.d(Const.LOG_TAG, "IS24 search finished. #flats: " + flats.size());
                b.putParcelableArrayList("flats", flats);
                receiver.send(STATUS_FINISHED, b);
                this.stopSelf();
                return;
            }
        }
        // no flats found
        Log.d(Const.LOG_TAG, "IS24 search finished with no flats: ");
        b.putString(Intent.EXTRA_TEXT, NO_FLATS);
    } catch (Exception e) {
        Log.e(Const.LOG_TAG, "IS24 search caught Exception: ", e);
    }
    receiver.send(STATUS_ERROR, b);
    this.stopSelf();
}

From source file:com.example.programming.proximityalerts.ProximityAlertService.java

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Location bestLocation = null;

        latitude = intent.getDoubleExtra(LATITUDE_INTENT_KEY, Double.MIN_VALUE);
        longitude = intent.getDoubleExtra(LONGITUDE_INTENT_KEY, Double.MIN_VALUE);
        radius = intent.getFloatExtra(RADIUS_INTENT_KEY, Float.MIN_VALUE);

        for (String provider : locationManager.getProviders(false)) {
            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 TODO;
            }/*from   w  w w  .j av a  2s.  c  o  m*/
            Location location = locationManager.getLastKnownLocation(provider);

            if (bestLocation == null) {
                bestLocation = location;
            } else {
                if (location.getAccuracy() < bestLocation.getAccuracy()) {
                    bestLocation = location;
                }
            }
        }

        if (bestLocation != null) {
            if (getDistance(bestLocation) <= radius) {
                inProximity = true;
            } else {
                inProximity = false;
            }
        }

        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);

        return START_STICKY;
    }

From source file:com.swetha.easypark.DisplayVacantParkingLots.java

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

    Intent displayIntent = getIntent();

    double usersCurrentLatitude = displayIntent.getDoubleExtra(GetParkingLots.LATITUDE,
            Constants.doubleDefaultValue);
    double usersCurrentLongitude = displayIntent.getDoubleExtra(GetParkingLots.LONGITUDE,
            Constants.doubleDefaultValue);
    fromTime = displayIntent.getLongExtra(GetParkingLots.FROMTIME, 0);
    toTime = displayIntent.getLongExtra(GetParkingLots.TOTIME, 0);

    isRadius = displayIntent.getBooleanExtra(GetParkingLots.RadiusOrZIPCODE, false);
    if (isRadius) {

        radius = displayIntent.getDoubleExtra(GetParkingLots.RADIUS, 0.0);
    } else {//from   ww w .ja v a2  s . c om

        zipcode = displayIntent.getLongExtra(GetParkingLots.ZIPCODE, 0);
    }

    Log.i("DisplayVacantParkingLots", "Before Calling Async task");
    new GetParkingLotsFromWebService(this, usersCurrentLatitude, usersCurrentLongitude, fromTime, toTime)
            .execute();
    Log.i("DisplayVacantParkingLots", "After Calling Async task");
    btn_switchToListView = (Button) findViewById(R.id.switchtolistview);
    btn_switchToListView.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (parkingLotsMapList != null) // fixed crashing of application when no parking data  found
            {
                Intent intent = new Intent(DisplayVacantParkingLots.this, DisplayParkingLotsAsList.class);
                intent.putExtra(ARRAYLISTMAP, parkingLotsMapList);
                startActivity(intent);
            }
        }
    });

}

From source file:com.location.philippweiher.test.SendMockLocationService.java

@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    // Get the type of test to run
    mTestRequest = startIntent.getAction();

    latitude = startIntent.getDoubleExtra(MapsActivity.LAT_FOR_POINT, 0);
    longitude = startIntent.getDoubleExtra(MapsActivity.LON_FOR_POINT, 0);

    /*/*www  .  j a va2s. c om*/
     * If the incoming Intent was a request to run a one-time or continuous test
     */
    if (TextUtils.equals(mTestRequest, MapsActivity.ACTION_START)) {

        // Get the pause interval and injection interval
        mPauseInterval = startIntent.getIntExtra(MapsActivity.EXTRA_PAUSE_VALUE, 2);
        mInjectionInterval = startIntent.getIntExtra(MapsActivity.EXTRA_SEND_INTERVAL, 1);

        // Create a location client
        mLocationClient = new LocationClient(this, this, this);

        // Start connecting to Location Services
        mLocationClient.connect();

    } else if (TextUtils.equals(mTestRequest, MapsActivity.ACTION_STOP_TEST)) {
        // Send a message back to the main activity that the test is stopping
        sendBroadcastMessage();

        // Stop this Service
        stopSelf();
    }

    /*
     * Tell the system to keep the Service alive, but to discard the Intent that
     * started the Service
     */
    return Service.START_STICKY;
}

From source file:io.github.data4all.service.MapTileService.java

private void doIntent(Intent intent) {

    if (intent != null) {
        long time = intent.getLongExtra(TIME, LASTTIME);
        if (time - LASTTIME > 5 * 60000 || MapViewActivity.UPDATECLICKABLE) {
            LASTTIME = time;/*from   w w  w .  ja  v a  2s  .  c o m*/
            MapViewActivity.UPDATECLICKABLE = true;
            double west = intent.getDoubleExtra(WEST, 0);
            double south = intent.getDoubleExtra(SOUTH, 0);
            double east = intent.getDoubleExtra(EAST, 0);
            double north = intent.getDoubleExtra(NORTH, 0);
            try {
                boolean empty = ChangesetUtil.getChangeSet(time, west, south, east, north).request();

                Log.d(TAG, "Check ChangeSets empty:" + empty);
                if (!empty) {
                    /*
                     * Creates a new Intent containing a Uri object
                     * BROADCAST_ACTION is a custom Intent action
                     */

                    Log.d(TAG, "New ChangeSets available");
                    Intent localIntent = new Intent(BROADCAST_MAP)
                            // Puts the status into the Intent
                            .putExtra(INTENT_UPDATE_TILES, true);
                    // Broadcasts the Intent to receivers in this app.
                    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
                }
            } catch (OsmException e) {
                Log.e(TAG, "" + e.toString());
            }
        }
    }
}

From source file:com.droid080419.droid080419.elevenfifty_nine.AltAddTaskActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ADD_TASK_REQUEST && resultCode == RESULT_OK) {
        if (data != null && data.hasExtra("LATITUDE") && data.hasExtra("LONGITUDE")) {
            coords = new LatLng(data.getDoubleExtra("LATITUDE", MapsActivity.UPD.latitude),
                    data.getDoubleExtra("LONGITUDE", MapsActivity.UPD.longitude));
            Log.d("MAPS", "EXTRas");
        }/*from ww  w.j a  v  a2 s . c  o  m*/
    }
    super.onActivityResult(requestCode, resultCode, data);
}