@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); }
// 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; }
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); }
// 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(); }
@Override public void onConnected(Bundle bundle) { mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(1000); // Update location every second LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, this); }
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); }
private LocationRequest getLocationRequest() { LocationRequest lr = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(LOCATION_UPDATE_INTERVAL); if (!mConstantReporting) { lr.setNumUpdates(MAX_LOCATION_UPDATES); } return lr; }
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(); } }
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); }
protected void initializeLocationRequest() { mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(60 * 1000) // 1 minute, in milliseconds .setFastestInterval(10 * 1000); // 10 seconds, in milliseconds }
private void initGPS() { if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } if (locationRequest == null) { locationRequest = new LocationRequest(); locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(10000) .setFastestInterval(5000); } googleApiClient.connect(); if (userAtConference()) { Log.d(TAG, "User checked in."); registerUserToConference(); giveFeedback(); deactivateButton(); Log.d(TAG, "Pairing users.."); pairUsers(); } else { Log.d(TAG, "User not in range of Conference. User is not checked in."); Toast.makeText(this, "Not in range of conference.", Toast.LENGTH_LONG).show(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); ClientAdd = getIntent().getStringExtra("add"); Clientinfo = getIntent().getStringExtra("inf"); mLocationRequest = LocationRequest.create(); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); clint_latlong = new LatLng( Double.parseDouble(getIntent().getStringExtra("lat")), Double.parseDouble(getIntent().getStringExtra("lon"))); tv = (TextView) findViewById(R.id.textViewMap); tv.setVisibility(View.VISIBLE); tv.setText("Wait..."); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); }
@AutoFactory public LocationProvider( @Provided GoogleApiAvailability googleApiAvailability, @Provided GoogleApiClient googleApiClient, @Provided FusedLocationProviderApi fusedLocationProviderApi, @Provided LocationManager locationManager, @Provided SensorManager sensorManager, @Provided Display displayManager, Context context, LocationCallback locationCallback) { this.mGoogleApiAvailability = googleApiAvailability; this.mGoogleApiClient = googleApiClient; this.mFusedLocationProviderApi = fusedLocationProviderApi; this.mLocationManager = locationManager; this.mContext = context; this.mLocationCallback = locationCallback; this.mSensorManager = sensorManager; this.mDisplay = displayManager; mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(INTERVAL_IN_MS) .setFastestInterval(FASTEST_INTERVAL_IN_MS); mNetworkLocationListener = createLocationListener(); mGpsLocationListener = createLocationListener(); determineIfUsingGms(); if (isUsingGms()) { mGoogleApiClient.registerConnectionCallbacks(this); mGoogleApiClient.registerConnectionFailedListener(this); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // listOfSongs = getListOfSongs(); // for (Song song : listOfSongs) { // Toast.makeText(getApplicationContext(), song.toString(), // Toast.LENGTH_LONG).show(); // } // Get a handle to the activity update list mStatusListView = (ListView) findViewById(R.id.log_listview); mStatusAdapter = new ArrayAdapter<Spanned>(this, R.layout.item_layout, R.id.log_text); mStatusListView.setAdapter(mStatusAdapter); mBroadcastManager = LocalBroadcastManager.getInstance(this); mBroadcastFilter = new IntentFilter(ActivityUtils.ACTION_REFRESH_STATUS_LIST); mBroadcastFilter.addCategory(ActivityUtils.CATEGORY_LOCATION_SERVICES); mDetectionRequester = new DetectionRequester(this); mDetectionRemover = new DetectionRemover(this); mLogFile = LogFile.getInstance(this); // for location locationClient = new LocationClient(this, this, this); // creating request object with some of parameters set locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(UPDATE_INTERVAL); }
@Override public void onCreate() { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(Application.locationUpdateTime); if (Application.locationMinDistance > 0) { locationRequest.setSmallestDisplacement(Application.locationMinDistance); } apiClient = new GoogleApiClient.Builder(getApplicationContext()) .addApi(LocationServices.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); apiClient.connect(); }
private void attachRecorder() { if (locationClientAPI == null) { connectToPlayAPI(); } else if (locationClientAPI.isConnected()) { Integer priority = translateDesiredAccuracy(config.getDesiredAccuracy()); LocationRequest locationRequest = LocationRequest.create() .setPriority(priority) // this.accuracy .setFastestInterval(config.getFastestInterval()) .setInterval(config.getInterval()); // .setSmallestDisplacement(config.getStationaryRadius()); LocationServices.FusedLocationApi.requestLocationUpdates( locationClientAPI, locationRequest, this); Log.d( TAG, "- locationUpdateReceiver NOW RECORDING!!!!!!!!!! with priority: " + priority + ", fastestInterval: " + config.getFastestInterval() + ", interval: " + config.getInterval() + ", smallestDisplacement: " + config.getStationaryRadius()); } else { locationClientAPI.connect(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); mapViewBuilder = new DefaultAirMapViewBuilder(this); map = (AirMapView) findViewById(R.id.map); textLogs = (TextView) findViewById(R.id.textLogs); logsScrollView = (ScrollView) findViewById(R.id.logsScrollView); map.setOnMapClickListener(this); map.setOnCameraChangeListener(this); map.setOnCameraMoveListener(this); map.setOnMarkerClickListener(this); map.setOnMapInitializedListener(this); map.setOnInfoWindowClickListener(this); map.initialize(getSupportFragmentManager()); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); // Create the LocationRequest object mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(10 * 1000) // 10 seconds, in milliseconds .setFastestInterval(1 * 1000); // 1 second, in milliseconds }
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate() + " + this.hashCode()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_nexrad_view); eventBusProvider.getEventBus().register(this); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); // Create the LocationRequest object mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_LOW_POWER) .setInterval(10 * 60 * 1000) // 10 seconds, in milliseconds .setFastestInterval(1 * 60 * 1000); // 1 second, in milliseconds if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) { ActivityCompat.requestPermissions(this, INITIAL_PERMS, INITIAL_REQUEST); } if (PreferenceManager.getDefaultSharedPreferences(this) .getString(SettingsActivity.KEY_PREF_NEXRAD_EMAILADDRESS, null) == null) { startSettings(true); } else { if (((NexradApp) getApplication()).getLastKnownLocation() != null) { RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); radarView.onEvent( new LocationChangeEvent(((NexradApp) getApplication()).getLastKnownLocation())); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); mProgressBar.setVisibility(View.INVISIBLE); mRefreshView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { getForecast(latitude, longitude); } }); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); mLocationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(10 * 1000) .setFastestInterval(1 * 1000); }
/** 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(); }
@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); }
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); }
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(); } }
/** start listen for location updates */ private void startUpdateLocation() { LocationRequest request = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_LOW_POWER) .setInterval(Consts.LOCATION_UPDATE_TIME) .setFastestInterval(Consts.LOCATION_UPDATE_TIME); locationClient.requestLocationUpdates(request, locationListener); SLog.d(TAG, "Location update started"); }
/** @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; } }
/* * 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); }