I know that from android 3.1 and above you can't turn on location services manually. But in Google maps it simply shows an dialog which prompts me to switch it on. This directly switches it on (In android 5.1 - Lollipop). So how does google do it? Is it some Google location services API I can use or should I direct the user to the location services settings screen?
Thanks.
The are making use of theSettingsApi It allows you to check if the location services are available on the device and there is a complete example provided by google on github that shows how to use this API. The sample code will prompt the user to enable location if it's switched off. The dialog that pops up when you fire the intent is similar to what you see in Google Maps.
Related
I managed to get a location object as per the documentation available in the Android Developers website (using the Location API offered by Google Play Services). Although I have specified service as the documentation instructs, I am never binding it/ starting it/ using it anywhere. I am doing something wrong?
No, you are not doing anything wrong. It is a requirement for devices with Android 10 (API level 29).
As Google Docs Says
When a foreground service is running, the system raises user awareness
by showing a persistent notification. Your app retains access when
it's placed in the background, such as when the user presses the Home
button on their device or turns their device's display off.
So basically if you are using location it will just show the notification to user if they have android 10 i.e API level 29
I have implemented a MusicPlayerService by following the official guide from the Android Developers site. At multiple places, I have found the information that this should be enough to make my app ready for Android Auto.
But if I open that (just the phone interface because I don't have a compatible car at the moment), the list of music providers just contains Google Music and the already installed VLC media player. To verify I also downloaded, compiled and installed the Universal Music Player example, which isn't showing up either.
Do I have to enable something or even upload the app to Google Play first?
EDIT: I now tested it with the Desktop Head Unit and it works. Afterwards the service is also visible on the phone interface. But this is not the expected behavior, right?
Only apps installed through Google Play will be shown in Android Auto. If you want to test your app with the phone interface, you'll need to enable developer mode and the 'unknown sources' option in the developer settings.
https://developer.android.com/training/auto/testing/index.html#phone
I'm developing an app using Ionic Framework. Within this app I have some geo uri encoded location links. In the upcoming Android-system option dialog where to choose an appropriate app to handle this intent it provides the following apps: Google Maps and Earth. As I have also OsmAnd installed it should also provide this as an option. Using 'geo:uri' intents from a native Android app does provide this option.
Does anyone has a clue why that happens and how to get this option?
Added
Within the ionic app I have this link:
Show
Angular is configured with:
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|geo):/);
This is what it looks like (my app using geo uri) and what it should look like (wiki entry with geo uri):
I am using Google Play Location Service to get location updates with high accuracy in my Android app as follows:
mLocationRequest=LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
My question is that if the app user has selected the battery saving location mode (see below image) in the device settings, then would the above request be able to get location updates with high accuracy or would I have to toggle the location mode programmatically? Or is getting the user change the location mode manually the only solution?
As always, many thanks to everyone helping out to point in the right direction!! :)
No, you can't change the user's location preference programatically. The user's preference overrides your LocationRequest priority and the permissions in your manifest file.
The best solution is to use a new API in the Google Play Services 7.0 lib which allows you to create the dialog (not directly but play services creates it for you) seen the screenshot in #mrek 's answer. You have to use a LocationSettingsRequest.Builder (reference).
According to this article, you cannot do that without superuser rights. However, Google Maps has this functionality, because it is a system (built-in) app:
Fortunately, (as iceman mentioned), if you have the latest version of Google Play services (7.0), you can use Location Settings Dialog.
You can find more information here.
I was trying to integrate a Google+ sign-in button into my app. I kept getting this "Unknown error" that no one seems to have an answer too and its apparently an error that has been happening a lot since Google released this at their I/O recently.
My SO thread on "Unknown error" here.
So my question is if this Google+ sign-in button even necessary for me to integrate Google Play Game Services (GPGS) into my app? If I use a feature of the GPGS, do I have to let the users log into Google+? Ultimately all I want is to use the leaderboard feature of the GPGS and couldn't care less if they are logged into Google+.
No buttons are truly necessary, but they are the best way to communicate to the user that they can sign in with Google. If you just want to use leaderboards, here's how to do it:
Perform setup and create your game's client ID as described in our docs.
Configure the leaderboard in the developer console.
Set up one or more test accounts to use to test your app.
Once that's done you're ready to start your code. Download the samples to serve as a starting point.
Import BaseGameUtils to your workspace.
Import the Google Play Services library project into your workspace (you can find it in the SDK manager under Extras, Google, Google Play Services)
Derive your Activity class from the sample's BaseGameActivity
Add a sign-in button in your layout (see sample's layout XML)
When the user clicks the button, call beginUserInitiatedSignIn().
When you get onSignInSucceeded, hide the sign-in button. Now you're ready to make any API calls, including submit leaderboard scores!
Hope this helps.
If not, please take a look at our Troubleshooting guide too, to see if there are any setup issues you might be overlooking.