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:com.dmsl.anyplace.SearchPOIActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // get the search type
        mSearchType = (SearchTypes) intent.getSerializableExtra("searchType");
        if (mSearchType == null)
            finishSearch("No search type provided!", null);

        // get the query string
        final String query = intent.getStringExtra("query");
        double lat = intent.getDoubleExtra("lat", 0);
        double lng = intent.getDoubleExtra("lng", 0);

        AnyplaceSuggestionsTask mSuggestionsTask = new AnyplaceSuggestionsTask(
                new AnyplaceSuggestionsTask.AnyplaceSuggestionsListener() {

                    @Override/*from ww w .  j av a 2s .  co  m*/
                    public void onSuccess(String result, List<? extends IPoisClass> pois) {

                        // we have pois to query for a match
                        mQueriedPoisStr = new ArrayList<Spanned>();
                        mQueriedPois = pois;

                        // Display part of Description Text Only
                        // Make an approximation of available space based on map size
                        final int viewWidth = (int) (findViewById(R.id.txtResultsFound).getWidth() * 2);
                        View infoWindow = getLayoutInflater()
                                .inflate(R.layout.queried_pois_item_1_searchactivity, null);
                        TextView infoSnippet = (TextView) infoWindow;
                        TextPaint paint = infoSnippet.getPaint();

                        // Regular expression
                        // ?i ignore case
                        Pattern pattern = Pattern.compile(String.format("((?i)%s)", query));

                        for (IPoisClass pm : pois) {
                            String name = "", description = "";
                            Matcher m;
                            m = pattern.matcher(pm.name());
                            // Makes matched query bold using HTML format
                            // $1 returns the regular's expression outer parenthesis value
                            name = m.replaceAll("<b>$1</b>");

                            m = pattern.matcher(pm.description());
                            if (m.find()) {
                                // Makes matched query bold using HTML format
                                // $1 returns the regular's expression outer parenthesis value
                                int startIndex = m.start();
                                description = m.replaceAll("<b>$1</b>");
                                description = AndroidUtils.fillTextBox(paint, viewWidth, description,
                                        startIndex + 3);
                            }
                            mQueriedPoisStr.add(Html.fromHtml(name + "<br>" + description));
                        }

                        ArrayAdapter<Spanned> mAdapter = new ArrayAdapter<Spanned>(
                                // getBaseContext(), R.layout.queried_pois_item_1,
                                getBaseContext(), R.layout.queried_pois_item_1_searchactivity, mQueriedPoisStr);
                        lvResultPois.setAdapter(mAdapter);
                        txtResultsFound.setText("Results found [ " + mQueriedPoisStr.size() + " ]");

                    }

                    @Override
                    public void onErrorOrCancel(String result) {
                        // no pois exist
                        finishSearch("No Points of Interest exist!", null);
                    }

                    @Override
                    public void onUpdateStatus(String string, Cursor cursor) {
                        SimpleCursorAdapter adapter = new SimpleCursorAdapter(getBaseContext(),
                                R.layout.queried_pois_item_1_searchactivity, cursor,
                                new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 },
                                new int[] { android.R.id.text1 });
                        lvResultPois.setAdapter(adapter);
                        txtResultsFound.setText("Results found [ " + cursor.getCount() + " ]");
                    }

                }, this, mSearchType, new GeoPoint(lat, lng), query);
        mSuggestionsTask.execute();

    }
}

From source file:eu.geopaparazzi.library.forms.views.GSketchView.java

@Override
public void setOnActivityResult(Intent data) {
    String absoluteImagePath = data.getStringExtra(LibraryConstants.PREFS_KEY_PATH);
    if (absoluteImagePath != null) {
        File imgFile = new File(absoluteImagePath);
        if (!imgFile.exists()) {
            return;
        }//from   w w  w .  ja v  a 2 s .  co m
        try {
            IImagesDbHelper imageHelper = DefaultHelperClasses.getDefaulfImageHelper();

            double lat = data.getDoubleExtra(LibraryConstants.LATITUDE, 0.0);
            double lon = data.getDoubleExtra(LibraryConstants.LONGITUDE, 0.0);
            double elev = data.getDoubleExtra(LibraryConstants.ELEVATION, 0.0);

            byte[][] imageAndThumbnailArray = ImageUtilities.getImageAndThumbnailFromPath(absoluteImagePath,
                    10);

            java.util.Date currentDate = new java.util.Date();
            String name = ImageUtilities.getSketchImageName(currentDate);
            long imageId = imageHelper.addImage(lon, lat, elev, -9999.0, currentDate.getTime(), name,
                    imageAndThumbnailArray[0], imageAndThumbnailArray[1], noteId);

            // delete the file after insertion in db
            imgFile.delete();

            _value = _value + GPictureView.IMAGE_ID_SEPARATOR + imageId;
            try {
                refresh(getContext());
            } catch (Exception e) {
                GPLog.error(this, null, e);
            }
        } catch (Exception e) {
            GPLog.error(this, null, e);
        }
    }
}

From source file:com.javadog.cgeowear.WearService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        final String action = intent.getAction();
        if (INTENT_INIT.equals(action)) {
            cacheName = intent.getStringExtra(EXTRA_CACHE_NAME);
            geocode = intent.getStringExtra(EXTRA_GEOCODE);

            final double latitude = intent.getDoubleExtra(EXTRA_LATITUDE, 0d);
            final double longitude = intent.getDoubleExtra(EXTRA_LONGITUDE, 0d);
            geocacheLocation = new Location("c:geo");
            geocacheLocation.setLatitude(latitude);
            geocacheLocation.setLongitude(longitude);

            //Connect to Google APIs
            if (apiClient != null) {
                apiClient.unregisterConnectionCallbacks(this);
                apiClient.unregisterConnectionFailedListener(this);
                apiClient.disconnect();/* w  w  w. j  a  v a  2s. co  m*/
            }
            apiClient = new GoogleApiClient.Builder(this, this, this).addApi(Wearable.API)
                    .addApi(LocationServices.API).build();
            apiClient.connect();
        }
    }

    return START_STICKY;
}

From source file:org.klnusbaum.udj.network.EventCommService.java

private void setEventData(Intent intent, AccountManager am, Account account) {
    am.setUserData(account, Constants.EVENT_NAME_DATA, intent.getStringExtra(Constants.EVENT_NAME_EXTRA));
    am.setUserData(account, Constants.EVENT_HOSTNAME_DATA,
            intent.getStringExtra(Constants.EVENT_HOSTNAME_EXTRA));
    am.setUserData(account, Constants.EVENT_HOST_ID_DATA,
            String.valueOf(intent.getLongExtra(Constants.EVENT_HOST_ID_EXTRA, -1)));
    am.setUserData(account, Constants.EVENT_LAT_DATA,
            String.valueOf(intent.getDoubleExtra(Constants.EVENT_LAT_EXTRA, -100.0)));
    am.setUserData(account, Constants.EVENT_LONG_DATA,
            String.valueOf(intent.getDoubleExtra(Constants.EVENT_LONG_EXTRA, -100.0)));
}

From source file:net.naonedbus.fragment.impl.ItineraireFragment.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (data != null) {
        final String address = data.getStringExtra("address");
        final double latitude = data.getDoubleExtra("latitude", 0d);
        final double longitude = data.getDoubleExtra("longitude", 0d);
        final Equipement.Type type = (Type) data.getSerializableExtra("type");
        final boolean currentLocation = data.getBooleanExtra("isCurrentLocation", false);

        if (requestCode == REQUEST_CODE_FROM) {
            mFromLocation.setLatitude(latitude);
            mFromLocation.setLongitude(longitude);
            mFromAddressTextView.setText(address);
            if (type == null) {
                mIconFromResId = currentLocation ? R.drawable.ic_action_locate_blue
                        : R.drawable.ic_directions_form_destination_notselected;
                mIconFromColor = Color.TRANSPARENT;
            } else {
                mIconFromResId = type.getDrawableRes();
                mIconFromColor = getActivity().getResources().getColor(type.getBackgroundColorRes());
            }//from ww  w  .j  a va  2 s  .  c  om

            mFromCurrentLocation = currentLocation;
        } else {
            mToLocation.setLatitude(latitude);
            mToLocation.setLongitude(longitude);
            mToAddressTextView.setText(address);
            if (type == null) {
                mIconFromResId = currentLocation ? R.drawable.ic_action_locate_blue
                        : R.drawable.ic_directions_form_destination_notselected;
                mIconToColor = Color.TRANSPARENT;
            } else {
                mIconToResId = type.getDrawableRes();
                mIconToColor = getActivity().getResources().getColor(type.getBackgroundColorRes());
            }

            mToCurrentLocation = currentLocation;
        }

        notifyIconsChanged();
    }

    onFormValueChange();
}

From source file:com.example.sleepintrain.CheckDistance.java

@Override
public void onResume() {
    super.onResume();

    Intent intent = getIntent();
    message = intent.getStringExtra(TestMap.EXTRA_MESSAGE);
    mdes = intent.getStringExtra(TestMap.EXTRA_DESTINATION);
    mlat = intent.getDoubleExtra(TestMap.EXTRA_MLAT, 0.00);
    mlng = intent.getDoubleExtra(TestMap.EXTRA_MLNG, 0.00);
    destinationMeters = intent.getIntExtra(TestMap.EXTRA_DMETER, 1500);

    // If the app already has a setting for getting location updates, get it
    if (mPrefs.contains(LocationUtils.KEY_UPDATES_REQUESTED)) {
        mUpdatesRequested = mPrefs.getBoolean(LocationUtils.KEY_UPDATES_REQUESTED, true);

        // Otherwise, turn off location updates until requested
    } else {//w  ww  . ja v a 2 s  .c  om
        mEditor.putBoolean(LocationUtils.KEY_UPDATES_REQUESTED, true);
        mEditor.commit();
    }

    mUpdatesRequested = true;
    //setDestination();
    listenGps();
}

From source file:com.pk.ubulance.Activity.DisplayDriverActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_driver);
    ButterKnife.bind(this);
    mContext = this;

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.activity_driver_screen);

    mDialog = ProgressDialog.show(this, "", "Booking Ubulance, Please wait...", true);
    //        callIntent = new Intent(Intent.ACTION_CALL);

    GetLocation getLocation = new GetLocation(this);
    if (getLocation.canGetLocation()) {
        mStartLatitude = Double.toString(getLocation.getLatitude());
        mStartLongitude = Double.toString(getLocation.getLongitude());
        mUserAddressTV//from ww  w . ja v  a 2  s.c o  m
                .setText(getLocationName(mContext, getLocation.getLatitude(), getLocation.getLongitude()));
        mShowUserLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String strUri = "http://maps.google.com/maps?q=loc:" + getLocation.getLatitude() + ","
                        + getLocation.getLongitude() + " (" + "You are here" + ")";
                Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri));

                intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");

                startActivity(intent);
            }
        });

    } else {
        getLocation.showSettingsAlert();
    }

    Intent intent = this.getIntent();
    Double mEndLatitude = intent.getDoubleExtra("mEndLatitude", 0.0);
    Double mEndLongitude = intent.getDoubleExtra("mEndLongitude", 0.0);
    mHospitalAddressTV.setText(intent.getStringExtra("vicinity"));
    mShowHospitalLocation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String strUri = "http://maps.google.com/maps?q=" + mHospitalAddressTV.getText().toString() + " ("
                    + "Hospital" + ")";
            Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri));

            intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");

            startActivity(intent);
        }
    });

    if (mEndLatitude != 0.0 || mEndLongitude != 0.0) {
        this.mEndLatitude = Double.toString(mEndLatitude);
        this.mEndLongitude = Double.toString(mEndLongitude);

    }

    if (isNetworkAvailable()) {
        UberAPI uberAPI = new UberAPI();
        mWorkOnProcess = true;
        try {

            uberAPI.callUbulance(this, mStartLatitude, mStartLongitude, this.mEndLatitude, this.mEndLongitude,
                    new ServerCallBack() {
                        @Override
                        public void onSuccess(Object result) throws JSONException {

                            final JSONObject finalResult = (JSONObject) result;

                            String product_id = finalResult.getString("product_id");
                            Log.d("Ubulance", "[FINAL] Product Id: " + product_id);

                            String request_id = finalResult.getString("request_id");
                            Log.d("Ubulance", "[FINAL] Product Id: " + request_id);

                            mStatusTV.setText("Status: " + finalResult.getString("status"));

                            final JSONObject pickup = finalResult.getJSONObject("pickup");
                            mEtaTV.setText("ETA: " + pickup.getString("eta") + "min");

                            final JSONObject driver = finalResult.getJSONObject("driver");
                            mDriverNameTV.setText("Driver: " + driver.getString("name"));
                            mDriverPhoneTV.setVisibility(View.VISIBLE);
                            mDriverPhoneTV.setText("Call: " + driver.getString("phone_number"));
                            mCallDriver.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    Intent intent = new Intent(Intent.ACTION_CALL);
                                    try {
                                        intent.setData(Uri.parse("tel:" + driver.getString("phone_number")));
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                    if (ActivityCompat.checkSelfPermission(getApplicationContext(),
                                            Manifest.permission.CALL_PHONE) != 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;
                                    }
                                    startActivity(intent);
                                }
                            });

                            mDriverRatingTV.setText("Rating: " + driver.getString("rating"));

                            final JSONObject vehicle = finalResult.getJSONObject("vehicle");
                            displayDriverImage(mContext, driver.getString("picture_url"));

                            mToggleIV.setOnClickListener(new View.OnClickListener() {
                                Boolean toggle = true;

                                @Override
                                public void onClick(View view) {

                                    try {
                                        if (toggle) {
                                            Glide.with(mContext).load(vehicle.getString("picture_url"))
                                                    .into(mToggleIV);
                                            toggle = false;
                                        } else {
                                            displayDriverImage(mContext, driver.getString("picture_url"));
                                            toggle = true;
                                        }

                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }

                                }
                            });

                            mVehicleMakeTV.setText("Make: " + vehicle.getString("make"));
                            mVehicleModelTV.setText("Model: " + vehicle.getString("model"));
                            mVehiclePlateTV.setText("Licence Plate: " + vehicle.getString("license_plate"));

                            mWorkOnProcess = false;
                            mDialog.dismiss();
                        }

                        @Override
                        public void onFailure(Boolean bool) {
                            mWorkOnProcess = false;
                        }
                    });
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else {
        Snackbar.make(mCoordinatorLayout, "No Internet. Please dial 911, if its emergency or try again later",
                Snackbar.LENGTH_LONG).show();
    }

}

From source file:com.nextgis.maplibui.service.TileDownloadService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("TileDownloadService", "Received start id " + startId + ": " + intent);
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.

    if (intent != null) {
        String action = intent.getAction();

        if (!TextUtils.isEmpty(action)) {
            switch (action) {
            case ACTION_ADD_TASK:
                String layerPathName = intent.getStringExtra(KEY_PATH);
                double dfMinX = intent.getDoubleExtra(KEY_MINX, 0);
                double dfMinY = intent.getDoubleExtra(KEY_MINY, 0);
                double dfMaxX = intent.getDoubleExtra(KEY_MAXX, GeoConstants.MERCATOR_MAX);
                double dfMaxY = intent.getDoubleExtra(KEY_MAXY, GeoConstants.MERCATOR_MAX);
                int zoomFrom = intent.getIntExtra(KEY_ZOOM_FROM, 0);
                int zoomTo = intent.getIntExtra(KEY_ZOOM_TO, 18);

                GeoEnvelope env = new GeoEnvelope(dfMinX, dfMaxX, dfMinY, dfMaxY);
                addTask(layerPathName, env, zoomFrom, zoomTo);
                return START_STICKY;
            case ACTION_STOP:
                if (Constants.DEBUG_MODE)
                    Log.d(Constants.TAG, "Cancel download queue");
                mQueue.clear();//from   w  ww .  jav  a  2 s . c  om
                mCanceled = true;
                cancelDownload();
                break;
            }

            startDownload();
        }
    }
    return START_STICKY;
}

From source file:com.example.sleepintrain.CheckDistance.java

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

    mVibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    Intent intent = getIntent();
    message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    mdes = intent.getStringExtra(TestMap.EXTRA_DESTINATION);
    mlat = intent.getDoubleExtra(TestMap.EXTRA_MLAT, 0.00);
    mlng = intent.getDoubleExtra(TestMap.EXTRA_MLNG, 0.00);
    destinationMeters = intent.getIntExtra(TestMap.EXTRA_DMETER, 1500);

    // Get handles to the UI view objects
    mDestination = (TextView) findViewById(R.id.destination);
    mDestination.setText(mdes);/*from w w w.  j  a  va 2 s. c  o m*/

    mLatLng = (TextView) findViewById(R.id.lat_lng);
    mDistance = (TextView) findViewById(R.id.distance);
    mStatus = (TextView) findViewById(R.id.status);
    mDistance.setText(Distance_Status_Default);
    mStatus.setText(Destination_Status_Default);

    adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            //.addTestDevice("F84FF00544A8000C28E55068B835F2BD")
            .build();

    adView.loadAd(adRequest);

    bStopUpdate = (Button) findViewById(R.id.stop_updates);
    //bStopUpdate.setVisibility(View.INVISIBLE);
    //mStatus.setText("Not reached");
    // mActivityIndicator = (ProgressBar) findViewById(R.id.address_progress);
    //mConnectionState = (TextView) findViewById(R.id.text_connection_state);
    //mConnectionStatus = (TextView) findViewById(R.id.text_connection_status);

    // Create a new global location parameters object
    // mLocationRequest = LocationRequest.create();
    /*
     * Set the update interval
     */
    ///mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

    // Use high accuracy
    // mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    // Set the interval ceiling to one minute
    // mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

    // Note that location updates are on when the app start to track the location
    mUpdatesRequested = true;

    // Open Shared Preferences
    mPrefs = getSharedPreferences(LocationUtils.SHARED_PREFERENCES, Context.MODE_PRIVATE);

    // Get an editor
    mEditor = mPrefs.edit();

    /*
     * Create a new location client, using the enclosing class to
     * handle callbacks.
     */
    // mLocationClient = new LocationClient(this, this, this);

    //intent = new Intent(CheckDistance.this, GpsReadingService.class);
    //pendingIntent = PendingIntent.getBroadcast(CheckDistance.this, 0, intent, 0);

    bind();
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

@Override
public void setOnActivityResult(Intent data) {

    Boolean hasPhoto = data.getBooleanExtra(LibraryConstants.OBJECT_EXISTS, false);
    String imgPath;//  w  ww. j ava  2s  .co  m

    if (hasPhoto) {// response of the CameraActivity with one image

        imgPath = data.getStringExtra(FormUtilities.PHOTO_COMPLETE_PATH);

        // TODO: save azimuth on database together with the picture.
        double azimuth = data.getDoubleExtra(LibraryConstants.AZIMUTH, 0);

        String uuid = java.util.UUID.randomUUID().toString();

        newImagesFromCamera.put(uuid, imgPath);
        updateValueForm();

        try {
            refresh(getContext());
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
    }
    if (data.hasExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW)) {
        Boolean hasPictureRemoved = data.getBooleanExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW, false);
        if (!hasPictureRemoved) {// response of the PictureActivity, used to remove image
            return;
        }

        String photoId = data.getStringExtra(FormUtilities.PICTURE_BITMAP_ID);

        if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session
            addedIdsToImageViews.remove(photoId);
            newImagesFromCamera.remove(photoId);
        } else if (_pictures.containsKey(photoId)) {// pictures from database
            _pictures.remove(photoId);
        }

        updateValueForm();

        try {
            refresh(getContext());
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
    }
}