Courtesy: GitHub
Warning: file_get_contents(../git/googlesamples/android-play-location/LocationUpdatesPendingIntent/README.md): failed to open stream: No such file or directory in /var/www/appsrox.com/public_html/ide/content.php on line 10

compileSdkVersion 25

applicationId "com.google.android.gms.location.sample.locationupdatespendingintent"

minSdkVersion 16

targetSdkVersion 25

versionCode 1

versionName "1.0"

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:25.3.1'

testCompile 'junit:junit:4.12'

compile 'com.android.support:design:25.3.1'

compile 'com.google.android.gms:play-services-location:11.0.0'

package com.google.android.gms.location.sample.locationupdatespendingintent

uses-permission

  • android.permission.ACCESS_FINE_LOCATION

MainActivity

Copyright 2017 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

The only activity in this sample. Displays UI widgets for requesting and removing location updates, and for the batched location updates that are reported. * Location updates requested through this activity continue even when the activity is not in the foreground. Note: apps running on "O" devices (regardless of targetSdkVersion) may receive updates less frequently than the interval specified in the {@link LocationRequest} when the app is no longer in the foreground.

The desired interval for location updates. Inexact. Updates may be more or less frequent.

The fastest rate for active location updates. Updates will never be more frequent than this value, but they may be less frequent.

The max time before batched results are delivered by location services. Results may be delivered sooner than this interval.

Stores parameters for requests to the FusedLocationProviderApi.

Provides access to the Fused Location Provider API.

Sets up the location request. Android has two location request settings: {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in the AndroidManifest.xml.

When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update interval (5 seconds), the Fused Location Provider API returns location updates that are accurate to within a few feet.

These settings are appropriate for mapping applications that show real-time location updates.

Return the current state of the permissions needed.

Callback received when a permissions request has been completed.

Handles the Request Updates button and requests start of location updates.

Handles the Remove Updates button, and requests removal of location updates.

Ensures that only one button is enabled at any time. The Start Updates button is enabled if the user is not requesting location updates. The Stop Updates button is enabled if the user is requesting location updates.

LocationUpdatesIntentService

Copyright 2017 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Handles incoming location updates and displays a notification with the location data. For apps targeting API level 25 ("Nougat") or lower, location updates may be requested using {@link android.app.PendingIntent#getService(Context, int, Intent, int)} or {@link android.app.PendingIntent#getBroadcast(Context, int, Intent, int)}. For apps targeting API level O, only {@code getBroadcast} should be used. Note: Apps running on "O" devices (regardless of targetSdkVersion) may receive updates less frequently than the interval specified in the {@link com.google.android.gms.location.LocationRequest} when the app is no longer in the foreground.

LocationUpdatesBroadcastReceiver

Copyright 2017 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Receiver for handling location updates. For apps targeting API level O {@link android.app.PendingIntent#getBroadcast(Context, int, Intent, int)} should be used when requesting location updates. Due to limits on background services, {@link android.app.PendingIntent#getService(Context, int, Intent, int)} should not be used. Note: Apps running on "O" devices (regardless of targetSdkVersion) may receive updates less frequently than the interval specified in the {@link com.google.android.gms.location.LocationRequest} when the app is no longer in the foreground.