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:org.akvo.caddisfly.ui.activity.MainActivity.java

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

    switch (requestCode) {
    case REQUEST_TEST:
        if (resultCode == Activity.RESULT_OK) {
            Intent intent = new Intent(getIntent());
            intent.putExtra("result", data.getDoubleExtra("result", -1));
            //intent.putExtra("questionId", mQuestionId);
            intent.putExtra("response", String.valueOf(data.getDoubleExtra("result", -1)));
            this.setResult(Activity.RESULT_OK, intent);
            finish();//www.  j a  v a2 s  .c o m
        } else {
            if (!PreferencesUtils.getBoolean(this, R.string.showStartPageKey, true)) {
                onBack();
                return;
            }
            //displayView(Config.CHECKLIST_SCREEN_INDEX, true);
        }
        break;
    default:
    }
}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case MapActivityBase.RC_GEOCODER:
        if (resultCode == Activity.RESULT_OK) {
            double lat = data.getDoubleExtra("lat", Double.NaN);
            double lon = data.getDoubleExtra("lon", Double.NaN);
            if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
                this.restoreMapState(null, lon, lat, null);
            }/*from  w w w.  ja v  a  2  s.  co  m*/
        }
        break;
    case MapActivityBase.RC_PREFERENCES:
        this.restart();
        break;
    }
}

From source file:org.digitalcampus.oppia.service.CourseIntallerService.java

@Override
protected void onHandleIntent(Intent intent) {

    if (intent.hasExtra(SERVICE_ACTION)) {
        boolean cancel = intent.getStringExtra(SERVICE_ACTION).equals(ACTION_CANCEL);
        //We have nothing more to do with a 'cancel' action than what is done in onStartCommand()
        if (cancel) {
            return;
        }//from www .  j  a v a2 s. c  o m
    }

    if (!intent.hasExtra(SERVICE_URL)) {
        Log.d(TAG, "No Course passed to the service. Invalid task");
        return;
    }

    if (intent.getStringExtra(SERVICE_ACTION).equals(ACTION_DOWNLOAD)) {
        String fileUrl = intent.getStringExtra(SERVICE_URL);
        String shortname = intent.getStringExtra(SERVICE_SHORTNAME);
        Double versionID = intent.getDoubleExtra(SERVICE_VERSIONID, 0);

        if (isCancelled(fileUrl)) {
            //If it was cancelled before starting, we do nothing
            Log.d(TAG, "Course " + fileUrl + " cancelled before started.");
            removeCancelled(fileUrl);
            removeDownloading(fileUrl);
            return;
        }
        boolean success = downloadCourseFile(fileUrl, shortname, versionID);
        if (success) {
            installDownloadedCourse(fileUrl, shortname, versionID);
        }
    } else if (intent.getStringExtra(SERVICE_ACTION).equals(ACTION_UPDATE)) {
        String scheduleURL = intent.getStringExtra(SERVICE_SCHEDULEURL);
        String shortname = intent.getStringExtra(SERVICE_SHORTNAME);
        updateCourseSchedule(scheduleURL, shortname);
    }

}

From source file:alaindc.crowdroid.View.MainActivity.java

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

    listGeofenceCircle = new HashMap<>();
    listCircles = new HashMap<>();

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    textView = (TextView) findViewById(R.id.textView);
    textView.setMovementMethod(new ScrollingMovementMethod());

    sensorsCheckbox = (CheckBox) findViewById(R.id.sensorscheck);
    requestsCheckbox = (CheckBox) findViewById(R.id.requestscheck);

    this.settingsButton = (Button) findViewById(R.id.settbutton);
    settingsButton.setOnClickListener(new View.OnClickListener() {
        @Override// w  ww  .  j  a va  2 s. c o m
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), StakeholdersActivity.class);
            startActivity(i);
        }
    });

    this.requestButton = (Button) findViewById(R.id.button);
    requestButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO: Disable
            //requestButton.setEnabled(false);

            // Start sending messages to server
            Intent serviceIntent[] = new Intent[Constants.MONITORED_SENSORS.length];
            for (int i = 0; i < Constants.MONITORED_SENSORS.length; i++) {
                serviceIntent[i] = new Intent(getApplicationContext(), SendIntentService.class);
                serviceIntent[i].setAction(Constants.ACTION_SENDDATA + Constants.MONITORED_SENSORS[i]);
                serviceIntent[i].putExtra(Constants.EXTRA_TYPE_OF_SENSOR_TO_SEND,
                        Constants.MONITORED_SENSORS[i]); // TODO Here set to send all kind of sensor for start
                getApplicationContext().startService(serviceIntent[i]);

            }
        }
    });

    this.sensorButton = (Button) findViewById(R.id.buttonLoc);
    sensorButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sensorButton.setEnabled(false);

            // Clear preferences
            getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE).edit().clear().commit();

            // Start service for PhoneListener
            Intent phoneListIntent = new Intent(getApplicationContext(), NeverSleepService.class);
            getApplicationContext().startService(phoneListIntent);

            // Start intent service for update position
            Intent posintent = new Intent(getApplicationContext(), PositionIntentService.class);
            getApplicationContext().startService(posintent);

            // Start intent service for update sensors
            Intent sensorintent = new Intent(getApplicationContext(), SensorsIntentService.class);
            sensorintent.setAction(Constants.INTENT_START_SENSORS);
            getApplicationContext().startService(sensorintent);

            // Start intent service for update amplitude sensing
            Intent amplintent = new Intent(getApplicationContext(), SensorsIntentService.class);
            amplintent.setAction(Constants.INTENT_START_AUDIOAMPLITUDE_SENSE);
            getApplicationContext().startService(amplintent);
        }
    });

    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Constants.INTENT_RECEIVED_DATA)) {
                String response = intent.getStringExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA);
                if (response != null && requestsCheckbox.isChecked())
                    textView.append(response + "\n");
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_POS)) {
                setLocationAndMap();
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_SENSORS)) {
                String response = intent.getStringExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA);
                if (response != null && sensorsCheckbox.isChecked())
                    textView.append(response + "\n");
            } else if (intent.getAction().equals(Constants.INTENT_UPDATE_GEOFENCEVIEW)) { // Geofencing
                addGeofenceView(intent.getIntExtra(Constants.INTENT_GEOFENCEEXTRA_SENSOR, 0),
                        intent.getDoubleExtra(Constants.INTENT_GEOFENCEEXTRA_LATITUDE, 0),
                        intent.getDoubleExtra(Constants.INTENT_GEOFENCEEXTRA_LONGITUDE, 0),
                        intent.getFloatExtra(Constants.INTENT_GEOFENCEEXTRA_RADIUS, 100));
            } else {
                Log.d("", "");
            }
        }
    };

    IntentFilter rcvDataIntFilter = new IntentFilter(Constants.INTENT_RECEIVED_DATA);
    IntentFilter updatePosIntFilter = new IntentFilter(Constants.INTENT_UPDATE_POS);
    IntentFilter updateSenseIntFilter = new IntentFilter(Constants.INTENT_UPDATE_SENSORS);
    IntentFilter updateGeofenceViewIntFilter = new IntentFilter(Constants.INTENT_UPDATE_GEOFENCEVIEW);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, rcvDataIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updatePosIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updateSenseIntFilter);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, updateGeofenceViewIntFilter);

}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
@Nullable/*from w  ww  .j a va2s .  com*/
public final View onCreateView(final LayoutInflater layoutInflater, final ViewGroup container,
        final Bundle savedInstance) {
    final View root = layoutInflater.inflate(R.layout.map_fragment, container, false);

    final Intent intent = getActivity().getIntent();
    // If any extra data was sent, store it.
    if (intent.getSerializableExtra("PLACE_DETAIL") != null) {
        centeredPlaceName = getActivity().getIntent().getStringExtra("PLACE_DETAIL");
    }
    if (intent.hasExtra("MIN_X")) {

        final double minX = intent.getDoubleExtra("MIN_X", 0);
        final double minY = intent.getDoubleExtra("MIN_Y", 0);
        final double maxX = intent.getDoubleExtra("MAX_X", 0);
        final double maxY = intent.getDoubleExtra("MAX_Y", 0);
        final String spatRefStr = intent.getStringExtra("SR");
        if (spatRefStr != null) {
            final Envelope envelope = new Envelope(minX, minY, maxX, maxY, SpatialReference.create(spatRefStr));
            mViewpoint = new Viewpoint(envelope);
        }
    }
    showProgressIndicator("Loading map");
    setUpMapView(root);
    return root;
}

From source file:it.geosolutions.geocollect.android.map.GeoCollectMapActivity.java

/**
 * center the map on the markers//  ww w  .j  a v  a 2  s.com
 */
public void centerMapFile() {
    MarkerOverlay mo = mapView.getMarkerOverlay();
    MapPosition mp = mapView.getMapViewPosition().getMapPosition();

    Intent intent = getIntent();
    if (intent.hasExtra(PARAMETERS.LAT) && intent.hasExtra(PARAMETERS.LON)
            && intent.hasExtra(PARAMETERS.ZOOM_LEVEL)) {
        double lat = intent.getDoubleExtra(PARAMETERS.LAT, 43.68411);
        double lon = intent.getDoubleExtra(PARAMETERS.LON, 10.84899);
        byte zoom_level = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL, (byte) 13);
        byte zoom_level_min = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MIN, (byte) 0);
        byte zoom_level_max = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MAX, (byte) 30);
        /*
         * ArrayList<MarkerDTO> list_marker = intent.getParcelableArrayListExtra(PARAMETERS.MARKERS); MarkerDTO mark = list_marker.get(0);
         */
        mp = new MapPosition(new GeoPoint(lat, lon), zoom_level);
        mapView.getMapViewPosition().setMapPosition(mp);
        mapView.getMapZoomControls().setZoomLevelMin(zoom_level_min);
        mapView.getMapZoomControls().setZoomLevelMax(zoom_level_max);
    } else {
        if (mo != null) {
            // support only one marker
            MapPosition newMp = MarkerUtils.getMarkerCenterZoom(mo.getMarkers(), mp);
            if (newMp != null) {
                mapView.getMapViewPosition().setMapPosition(newMp);
            }
        }
    }
}

From source file:com.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java

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

    Intent intent = interaction.getIntentMovie();
    String movieId = null;/*from  w ww .  j a v  a 2  s.com*/
    String theaterId = null;
    boolean fromWidget = intent.getBooleanExtra(ParamIntent.ACTIVITY_MOVIE_FROM_WIDGET, false);
    String near = intent.getStringExtra(ParamIntent.ACTIVITY_MOVIE_NEAR);
    Log.i(TAG, "From Widget : " + fromWidget);
    MovieBean movie = null;
    TheaterBean theater = null;
    // if (fromWidget) {
    //
    // Object[] currentMovie = extractCurrentMovie();
    // if (currentMovie != null) {
    // theater = (TheaterBean) currentMovie[0];
    // movie = (MovieBean) currentMovie[1];
    // }
    // } else {
    movieId = intent.getStringExtra(ParamIntent.MOVIE_ID);
    movie = intent.getParcelableExtra(ParamIntent.MOVIE);
    theaterId = intent.getStringExtra(ParamIntent.THEATER_ID);
    theater = intent.getParcelableExtra(ParamIntent.THEATER);
    double latitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LATITUDE, -1);
    double longitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LONGITUDE, -1);
    if ((latitude != -1) && (longitude != -1)) {
        Location gpsLocation = new Location("GPS"); //$NON-NLS-1$
        gpsLocation.setLatitude(latitude);
        gpsLocation.setLongitude(longitude);
        model.setGpsLocation(gpsLocation);
    } else {
        model.setGpsLocation(null);
    }
    // }
    Log.i(TAG, "Movie ID : " + movieId);

    model.setMovie(movie);
    moviePagedAdapter.changeData(movie, interaction.getMainContext(), model, tracker, this);
    moviePagedAdapter.notifyDataSetChanged();

    if (theaterId != null) {
        model.setTheater(theater);
    }

    moviePagedAdapter.manageViewVisibility();

    try {
        moviePagedAdapter.fillBasicInformations(movie);

        if (isServiceRunning()) {
            interaction.openDialog();
        }

        if (movie.getImdbId() == null) {
            tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category
                    , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                    , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 0 // Label
                    , 0 // Value
            );
            searchMovieDetail(movie, near);
        } else {
            tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category
                    , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                    , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 1 // Label
                    , 0 // Value
            );
            moviePagedAdapter.fillViews(movie);
        }
    } catch (Exception e) {
        Log.e(TAG, "error on create", e); //$NON-NLS-1$
    }
}

From source file:com.mumu.pokemongogo.HeadService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LatLng mapLocation;/*from   ww w  .j av  a 2 s .  c  o  m*/
    double mapRadius;

    if (intent != null) {
        final String action = intent.getAction();
        if (action != null) {
            configHeadIconShowing(HeadIconView.VISIBLE);

            switch (action) {
            case ACTION_HANDLE_NAVIGATION:
                mapLocation = intent.getParcelableExtra(EXTRA_DATA);
                Log.d(TAG, "Service receive LAT = " + mapLocation.latitude + " and LONG = "
                        + mapLocation.longitude);
                mMapLocation = mapLocation;
                mMessageText = mContext.getString(R.string.msg_map_navigating);
                doMapNavigation();
                break;
            case ACTION_HANDLE_TELEPORT:
                mapLocation = intent.getParcelableExtra(EXTRA_DATA);
                Log.d(TAG, "Service receive LAT = " + mapLocation.latitude + " and LONG = "
                        + mapLocation.longitude);
                mMapLocation = mapLocation;
                mMessageText = mContext.getString(R.string.msg_map_teleporting);
                doMapTeleporting();
                break;
            case ACTION_HANDLE_INCUBATING:
                mapRadius = intent.getDoubleExtra(EXTRA_DATA, 50.0);
                Log.d(TAG, "Service receive Radius = " + mapRadius);
                mAutoIncubatingRadius = mapRadius;
                mMessageText = mContext.getString(R.string.msg_start_incubating);
                mHeadIconList.get(IDX_INCUBATOR_ICON).getImageView()
                        .setImageResource(R.drawable.ic_egg_enabled);
                mHeadIconList.get(IDX_SPEED_ICON).getImageView().setImageResource(R.drawable.ic_slow);
                mAutoIncubating = true;
                startAutoIncubating();
                break;
            }
        }
    }
    return START_NOT_STICKY;
}

From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java

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

    if (!mServiceIsBound) {
        addOnServiceBoundRunnable(new SafeRunnable() {
            @Override// w w w .ja  va2s .  c o  m
            protected void safeRun() throws Exception {
                onActivityResult(requestCode, resultCode, data);
            }
        });
        return;
    }

    switch (requestCode) {
    case PICK_CONTACT:
        if (resultCode == Activity.RESULT_OK) {
            Uri contactData = data.getData();
            Cursor c = managedQuery(contactData, null, null, null, null);
            if (c.moveToFirst()) {
                try {
                    String number = c
                            .getString(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
                    String name = c.getString(c.getColumnIndexOrThrow(
                            ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME));
                    mActionView.setText(number);
                    if (mCaptionView.getText().equals(""))
                        mCaptionView.setText(getString(R.string.caption_call, new Object[] { name }));
                } catch (IllegalArgumentException e) {
                    L.bug("Could not get phone number from list.", e);
                }
            }
        }
        break;
    case GET_LOCATION:
        if (resultCode == Activity.RESULT_OK) {
            mActionView.setText(data.getDoubleExtra("latitude", 0) + "," + data.getDoubleExtra("longitude", 0));
        }
        break;
    }
}