forked from android/location-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created sample showing use of location settings dialog
Change-Id: Idd982619bfe5f67b94db4a1269865f818f093a52
- Loading branch information
Showing
24 changed files
with
1,094 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build/ | ||
.idea | ||
.gradle | ||
*.iml | ||
local.properties | ||
app/libs | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Location Settings | ||
================= | ||
|
||
|
||
Demonstrates how to use the Location SettingsApi to check if a device has the | ||
location settings required by an application, and optionally provide a location | ||
dialog to update the device's location settings. | ||
|
||
Introduction | ||
============ | ||
|
||
This sample builds on the LocationUpdates sample included in this repo, | ||
and allows the user to update the device's location settings using a location | ||
dialog. | ||
|
||
Uses the | ||
[SettingsApi](https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html) | ||
to ensure that the device's system settings are properly configured for the | ||
app's location needs. When making a request to Location services, the device's | ||
system settings may be in a state that prevents the app from obtaining the | ||
location data that it needs. For example, GPS or Wi-Fi scanning may be switched | ||
off. The | ||
[SettingsApi](https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html) | ||
makes it possible to determine if a device's system settings are adequate for | ||
the location request, and to optionally invoke a dialog that allows the user to | ||
enable the necessary settings. | ||
|
||
This sample allows the user to request location updates using the | ||
ACCESS_FINE_LOCATION setting (as specified in AndroidManifest.xml). The sample | ||
requires that the device has location enabled and set to the "High accuracy" | ||
mode. If location is not enabled, or if the location mode does not permit high | ||
accuracy determination of location, the activity uses the `SettingsApi` | ||
to invoke a dialog to allow the user to upgrade the device's settings. | ||
|
||
This sample uses | ||
[Google Play services (GoogleApiClient)](https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html) | ||
and the | ||
[FusedLocationApi] (https://developer.android.com/reference/com/google/android/gms/location/LocationServices.html). | ||
|
||
To run this sample, **disable location or pick any location mode other than | ||
the "High accuracy" mode.** | ||
|
||
|
||
Prerequisites | ||
-------------- | ||
|
||
- Android API Level >v9 | ||
- Android Build Tools >v21 | ||
- Google Support Repository | ||
|
||
Getting Started | ||
--------------- | ||
|
||
This sample uses the Gradle build system. To build this project, use the | ||
"gradlew build" command or use "Import Project" in Android Studio. | ||
|
||
Support | ||
------- | ||
|
||
- Stack Overflow: http://stackoverflow.com/questions/tagged/google-play-services | ||
|
||
If you've found an error in this sample, please file an issue: | ||
https://github.com/googlesamples/android-play-location/issues | ||
|
||
Patches are encouraged, and may be submitted according to the instructions in | ||
CONTRIBUTING.md. | ||
|
||
License | ||
------- | ||
|
||
Copyright 2014 Google, Inc. | ||
|
||
Licensed to the Apache Software Foundation (ASF) under one or more contributor | ||
license agreements. See the NOTICE file distributed with this work for | ||
additional information regarding copyright ownership. The ASF licenses this | ||
file to you 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "21.1.2" | ||
|
||
defaultConfig { | ||
applicationId "com.google.android.gms.location.sample.locationsettings" | ||
minSdkVersion 9 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
repositories { | ||
mavenCentral() | ||
flatDir { | ||
dirs 'libs' | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:22.0.0' | ||
// TODO: remove before submitting. | ||
compile 'com.google.android.gms:google-play-services-7093000@aar' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/shailentuli/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.android.gms.location.sample.locationsettings" > | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | ||
</manifest> |
Oops, something went wrong.