예제 #1
0
 // creates location request
 private LocationRequest createLocationRequest() {
   LocationRequest mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(Config.LOCATION_TRACKER_UPDATE_PERIOD);
   mLocationRequest.setFastestInterval(Config.LOCATION_TRACKER_UPDATE_PERIOD_MIN);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
   return mLocationRequest;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // UI widgets
    _textViewLatLng = (TextView) findViewById(R.id.lat_lng);
    _textViewAddress = (TextView) findViewById(R.id.address);
    _textViewConnectionState = (TextView) findViewById(R.id.text_connection_state);
    _textViewConnectionStatus = (TextView) findViewById(R.id.text_connection_status);
    _activityIndicatior = (ProgressBar) findViewById(R.id.address_progress);

    _locationRequest = LocationRequest.create();

    _locationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

    _locationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

    _updatesRequested = false;

    _prefs = getSharedPreferences(LocationUtils.SHARED_PREFERENCES, Context.MODE_PRIVATE);

    _editor = _prefs.edit();

    _locationClient = new LocationClient(this, this, this);
  }
 private void createLocationRequest() {
   locationRequest = new LocationRequest();
   locationRequest.setInterval(interval);
   locationRequest.setFastestInterval(interval / 3);
   locationRequest.setPriority(priority);
   locationRequest.setSmallestDisplacement(minDisplacement);
 }
 /** Creating location request object */
 protected void createLocationRequest() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(UPDATE_INTERVAL);
   mLocationRequest.setFastestInterval(FATEST_INTERVAL);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
   mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
 }
예제 #5
0
 protected LocationRequest getRequest() {
   // Create the Google API location request
   LocationRequest locationRequest = new LocationRequest();
   locationRequest.setInterval(0);
   locationRequest.setFastestInterval(0);
   locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
   return locationRequest;
 }
 protected void startLocationUpdates() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
   mLocationRequest.setInterval(UPDATE_INTERVAL);
   mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
   LocationServices.FusedLocationApi.requestLocationUpdates(
       mGoogleApiClient, mLocationRequest, this);
 }
예제 #7
0
 // auto getLocation
 protected void createLocationRequest() {
   // Toast.makeText(this,"in createLocationRequest", Toast.LENGTH_SHORT).show();
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(10000);
   mLocationRequest.setFastestInterval(5000);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
   // Toast.makeText(this,"in end of createLocationRequest", Toast.LENGTH_SHORT).show();
 }
  private void startLocationUpdates() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(getTimeToUpdateYourLocation() * 1000);
    mLocationRequest.setFastestInterval(getTimeToUpdateYourLocation() * 1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationServices.FusedLocationApi.requestLocationUpdates(
        mGoogleApiClient, mLocationRequest, this);
  }
예제 #9
0
  public LocationRequest createLocationRequest() {
    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setInterval(UPDATE_INTERVAL);
    locationRequest.setFastestInterval(FASTEST_INTERVAL);
    locationRequest.setExpirationDuration(ACCEPTED_LOCATION_AGE_MILLIS);
    locationRequest.setNumUpdates(5);

    return locationRequest;
  }
예제 #10
0
 public LocationRequest getLocationRequest() {
   long INTERVAL = 0;
   long FASTEST_INTERVAL = 0;
   if (mLocationRequest == null) {
     mLocationRequest = new LocationRequest();
     mLocationRequest.setInterval(INTERVAL);
     mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
     mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
   }
   return mLocationRequest;
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ctx = getApplicationContext();
    activity = this;
    setContentView(R.layout.camera);
    setFields();

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setInterval(2000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setFastestInterval(1000);

    mLocationClient = new LocationClient(getApplicationContext(), this, this);

    // get objects
    if (savedInstanceState != null) {
      Log.e(LOG, "##### savedInstanceState is LOADED");
      type = savedInstanceState.getInt("type", 0);
      projectSite = (ProjectSiteDTO) savedInstanceState.getSerializable("projectSite");
      project = (ProjectDTO) savedInstanceState.getSerializable("project");
      String path = savedInstanceState.getString("photoFile");
      if (path != null) {
        photoFile = new File(path);
      }
    } else {
      type = getIntent().getIntExtra("type", 0);
      project = (ProjectDTO) getIntent().getSerializableExtra("project");
      projectSite = (ProjectSiteDTO) getIntent().getSerializableExtra("projectSite");
      projectSiteTask = (ProjectSiteTaskDTO) getIntent().getSerializableExtra("projectSiteTask");
      companyStaff = (CompanyStaffDTO) getIntent().getSerializableExtra("companyStaff");
    }
    Log.e(LOG, "###### type: " + type);

    if (savedInstanceState != null) {
      String path = savedInstanceState.getString("filePath");
      if (path != null) {
        Log.w(LOG, "###### file path is: " + path);
        currentFullFile = new File(path);
        currentThumbFile = new File(savedInstanceState.getString("thumbPath"));
        try {
          Bitmap bm = ImageUtil.getBitmapFromUri(ctx, Uri.fromFile(currentFullFile));
          image.setImageBitmap(bm);
        } catch (Exception e) {
          e.printStackTrace();
        }
      } else {
        dispatchTakePictureIntent();
      }
    } else {
      dispatchTakePictureIntent();
    }
  }
예제 #12
0
  protected void createLocationRequest() {
    mLocationRequest = new LocationRequest();

    // Sets the desired interval for active location updates. This interval is
    // inexact. You may not receive updates at all if no location sources are available, or
    // you may receive them slower than requested. You may also receive updates faster than
    // requested if other applications are requesting location at a faster interval.
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);

    // Sets the fastest rate for active location updates. This interval is exact, and your
    // application will never receive updates faster than this value.
    mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);

    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  }
 /** Runs when a GoogleApiClient object successfully connects. */
 @Override
 public void onConnected(Bundle connectionHint) {
   Log.i(TAG, "onConnected() - connected to Google API.");
   // set the parameters for our location determination.
   LocationRequest locRequest;
   locRequest = LocationRequest.create();
   locRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
   // These intervals should not really matter because we stop the
   // request after we receive the first result in onLocationChanged()
   locRequest.setInterval(10 * 1000); // 10 seconds.
   locRequest.setFastestInterval(1 * 1000); // 1 second
   // Request location updates - on LocationChanged is called each time
   // we get a new location notification.
   LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locRequest, this);
   Log.i(TAG, "onConnected() - requesting location updates");
   Toast.makeText(mContext, "Requesting Location....", Toast.LENGTH_LONG).show();
 }
예제 #14
0
  @Override
  public void onCreate() {

    // Create a new global location parameters object
    _LocationRequest = LocationRequest.create();

    _LocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);

    _LocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    _LocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);

    /*
     * Create a new location client, using the enclosing class to
     * handle callbacks.
     */
    _locationClient = new LocationClient(_context.getContext(), this, this);
  }
예제 #15
0
  public Locator(
      Context context, LocationListener locationListener, ConnectionCallbacks callbacks) {
    this.context = context;
    this.locationListener = locationListener;
    this.callbacks = callbacks;

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setFastestInterval(FAST_INTERVAL_CEILING_IN_MILLISECONDS);

    mUpdatesRequested = false;

    mPrefs = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
    mEditor = mPrefs.edit();

    mLocationClient = new LocationClient(context, this, this);
  }
예제 #16
0
  public LocationService(Activity locationActivity) {

    locationRequest = LocationRequest.create();
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setInterval(INTERVAL);
    locationRequest.setFastestInterval(FASTEST_INTERVAL);
    this.locationActivity = locationActivity;

    googleApiClient =
        new GoogleApiClient.Builder(locationActivity)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    if (googleApiClient != null) {
      googleApiClient.connect();
    }
  }
예제 #17
0
  /** @brief This function starts the GPS */
  private void startLocation(boolean quick) {
    // Check if we need to set up Google API
    if (!sGPSIsOn) {
      Log.e(TAG, "starting location?");
      if (sGoogleApi == null) {
        // Build API
        sGoogleApi =
            new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();

        // Thank the 6 God for blockingConnect
        ConnectionResult what = sGoogleApi.blockingConnect();
      }

      if (sLocationIntent == null) {
        Intent intent = new Intent(this, InnerLocationService.class);
        sLocationIntent =
            PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      }

      if (quick) {
        sQuickGPSIsOn = true;
      }

      long interval = quick ? 0 : 20000;
      LocationRequest locRequest = new LocationRequest();
      if (quick) {
        sQuickGPSIsOn = true;
        locRequest.setNumUpdates(2);
      }

      locRequest.setInterval(interval);
      locRequest.setFastestInterval(interval);
      locRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
      LocationServices.FusedLocationApi.requestLocationUpdates(
          sGoogleApi, locRequest, sLocationIntent);
      sGPSIsOn = true;
    }
  }
예제 #18
0
  /*
   * Initialize the Activity
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_location);

    // Get handles to the UI view objects
    mLatLng = (TextView) findViewById(R.id.lat_lng);
    mAddress = (TextView) findViewById(R.id.address);
    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 off until the user turns them on
    mUpdatesRequested = false;

    // 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);
  }
  @Override
  public void onConnected(Bundle bundle) {
    Log.w(LOG, "## onConnected ");
    location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if (location != null) {
      Log.w(
          LOG,
          "## onConnected location ....lastLocation: "
              + location.getLatitude()
              + " "
              + location.getLongitude()
              + " acc: "
              + location.getAccuracy());
      // getLocations();
    }

    locationRequest = LocationRequest.create();
    locationRequest.setInterval(2000);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setFastestInterval(1000);
  }
예제 #20
0
 protected void createLocationRequest() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(INTERVAL);
   mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
 }
예제 #21
0
 protected void createLocationRequest() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(5000);
   mLocationRequest.setFastestInterval(1000); //   1 second
   mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
 }
 protected void createLocationRequest() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(Constantes.UPDATE_INTERVAL);
   mLocationRequest.setFastestInterval(Constantes.FASTEST_INTERVAL);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
 }
예제 #23
0
 protected void createLocationRequest() {
   mLocationRequest = new LocationRequest();
   mLocationRequest.setInterval(1000 * 10);
   mLocationRequest.setFastestInterval(1000 * 5);
   mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
 }
예제 #24
0
 private void initLocationRequest() {
   mLocationRequest = LocationRequest.create();
   mLocationRequest.setFastestInterval(1000);
   mLocationRequest.setInterval(1000);
 }