Can ActivityRecognition API work without a data connection? - android

I am looking to use the Google Play Service ActivityRecognition API as part of an Android app which will be offline for most of its usage; users will generally be out and about and a data connection is not guaranteed.
Looking at the docs, the requestActivityUpdates method requires a connected GoogleApiClient.
My question is, is the Activity Recognition API guaranteed to work if there is no data connection present?

Sure it works without data connection.
Google Play services is basically the background app that is running in the Android OS. Thus by requesting connection to GoogleApiClient you are connecting to this Google Play services app.
It is said that Google Play services apk does silent updates, however it is better to check if it is updated to the latest version, since sometimes services fail to update (happened with me only on Android 2.3).

Related

Can't connect to google play service

I had an android application working fine in all average smartphones, but only one client is using a custom phone from Huawei, he received this error Can't connect to google play service, and also Google Maps not working, so my question there's any way programmatically to send a request to download the missed google play service ?
You can't install Google Play Services like a normal application, since it isn't a normal application. It's actually at least 3.
It needs to be a system app (ie in /system/priv-app/) to work, and relies on certain other frameworks that can't simply be installed.
If this user is rooted, tell them to flash Google Play Services from something like OpenGApps or MicroG. Otherwise, if you need people without Google Services to use your app, you need to find another maps API that isn't from Google.

Getting CurrentLocation 0 using fused location when google play service is different in app and device

I am trying to get Current location using Fusedlocationservice.
In my gradle file i have put below playservice version
compile 'com.google.android.gms:play-services:9.4.0'
Now if in device have latest version of google playservice then its work well. it give proper location.
But if device have lower version then its not give current location.
Its also give warning in logcat like below:
W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 6184738
So its mandatory to have latest version of playservice in device to get current location..?
If yes then i need alternet solution for this. because every user not able to update service in device so.
my code you can see here .Get Current Location 0 in marshmallow where below 23 API its give exact current Location using fused Location
Any Help will highly appreciated.
as far as i know FusedLocation was added in Play Service 7.0 and the one you posted is 6184738 is 6.1 i guess, you can check here all the release changelog, so it should work on devices with play services 7.0 or higher
You might want to check this document: Ensure Devices Have the Google Play services APK
As described in the Google Play services overview, Google Play delivers service updates for users on Android 2.3 and higher through the Google Play Store app. However, updates might not reach all users immediately, so your app should verify the version available before attempting to perform API transactio
You are strongly encouraged to use the GoogleApiClient class to access Google Play services features. This approach allows you to attach an OnConnectionFailedListener object to your client. To detect if the device has the appropriate version of the Google Play services APK, implement the onConnectionFailed() callback method. If the connection fails due to a missing or out-of-date version of the Google Play APK, the callback receives an error code such as SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED. To learn more about how to build your client and handle such connection errors, see Accessing Google APIs.
Another approach is to use the isGooglePlayServicesAvailable() method. You might call this method in the onResume() method of the main activity. If the result code is SUCCESS, then the Google Play services APK is up-to-date and you can continue to make a connection. If, however, the result code is SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then the user needs to install an update. In this case, call the getErrorDialog() method and pass it the result error code. The method returns a Dialog you should show, which provides an appropriate message about the error and provides an action that takes the user to Google Play Store to install the update.
Note: Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK before you access Google Play services features.
Hope it helps!
I have put google play service version to 7.3 in gradle instead of latest version.
Because every user not have latest version of play service so if you put latest version of play service in application it always take null location if device have lower version play service. else user have to update play service to match application play service version.
So I have put lower version of playservice in app. build so its supports in each device which have equal or higher version.
got reference from doc. https://developers.google.com/android/guides/setup#ensure_devices_have_the_google_play_services_apk

Firebase for Play Services below 9

The Background
My app is heavily dependent on Firebase. I use most of the services like Authentication, Realtime database, Storage, Analytics, Crash Reporting and more.
Everything works fine so far, but I have a doubt regarding a particular scenario.
The Problem
As Firebase was introduced in Play Services 9, what will happen to those devices who have still not updated to Play Services 9.
How will my app work on those devices as my app is heavily dependent on Firebase?
How does Firebase cater to the scenario of backporting?
Or should the developers some how check the version of Play Services and request the user to update?
How will my app work on those devices as my app is heavily dependent on Firebase?
When installing the application, it will prompt them a message saying that this app requires a higher version of Play Services. So it will work properly.
How does Firebase cater to the scenario of backporting?
Firebase needs a minimum API of 9. If the device doesn't support anything that's missing from the device, it will simply tell them, so you don't have to worry.
Or should the developers some how check the version of Play Services and request the user to update?
NO, Android does this for you.
i have edited my answer to make things a bit more clear
1. How will my app work on those devices as my app is heavily dependent on Firebase?
Android automatically checks for the play services version that is currently installed in the user's device and prompts the user to update to the play services version that the application was built with Firebase.
2. How does Firebase cater to the scenario of backporting?
Firebase explicitly outlines the latest version of play services as a prerequisite for building with it, there is no information on the docs about back porting so I don't think it is possible at the moment.
3. Or should the developers some how check the version of Play Services and request the user to update?
I wouldn't recommend this as Android already checks and pops up a play services error. However it is quite possible to check the version of play services and request the user to first update it in order to use your application, more info on this can be found on this link isGooglePlayServicesAvailable(Context)

Android Google Play Services API for GPS only?

this might seem like a very stupid question to you, but I haven't found any answer to it yet.
In Android, there are two possibilities of making the application location aware. a) with the Android Location API or b) with the Google Play Services API. It is recommended to use the Google Play Services API since it's less battery draining and provides more accuracy.
But what if I only wanted to use GPS? No additional accuracy by combining some mobile data etc. Just plain GPS without having any internet connection. Is it still preferable to use the Google Play Services API? Also, does it require internet connection at some point? The onConnect() method is supposed to be called when a connection to the GoogleApiClient is established. Does that mean that a connection to a Google Server is needed or only that the locally saved Google Play Services (on the device) is connected to?

How to disable Google play services by code?

I am creating an app where I need to analyse spector of my signal. And when this service is on I got some filtered HZs, When I stop this service everything is ok.
In my app I need to disable Google play services by code when my app runs.
Is there any idea how can disable the services (Force Stop) by code ?
Your code is not allowed to force a stop of Google Play services by design and by contract. You can connect and disconnect your own clients at-will, but other apps on the device may be using the services and you are not allowed to interfere with them.
What services on the phone are you using that you suspect Google Play services is interfering with?
According to the android documentation: The GoogleApiClient class is The main entry point for Google Play services integration.
So in order to disable Google Play Services functionality. Try calling GoogleApiClient.disconnect(); on your GoogleApiClient object.
Hopefully that should work.

Categories

Resources