Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] is location detection required google play services android studio

Posted on November 11, 2022 By

Solution 1 :

By checking your code here https://github.com/mostafa-n3ma/Pcm-helper1.0/blob/master/app/build.gradle#L69

Are you sure you are not dependent on the google play service library?

Solution 2 :

this is the problem

    private fun checkDeviceLocationSettingsAndGetLocationUpdates(resolve: Boolean = true) {
    val locationRequest = com.google.android.gms.location.LocationRequest.create().apply {
        priority = LocationRequest.QUALITY_LOW_POWER
    }
    val builder = LocationSettingsRequest.Builder().addLocationRequest(locationRequest)

    val settingsClint = LocationServices.getSettingsClient(requireActivity())
    val locationSettingsResponseTask = settingsClint.checkLocationSettings(builder.build())

    locationSettingsResponseTask.addOnFailureListener { exeption ->
        if (exeption is ResolvableApiException && resolve) {
            try {
                startIntentSenderForResult(
                    exeption.resolution.intentSender,
                    REQUEST_TURN_DEVICE_LOCATION_ON,
                    null,
                    0, 0, 0,
                    null
                )
            } catch (sendEx: IntentSender.SendIntentException) {
                Log.d(TAG, "Error geting location settings resolution: " + sendEx.message)
            }
        } else {
            Snackbar.make(
                this.requireView(),
                "Location services must be enabled to use the app", Snackbar.LENGTH_INDEFINITE
            ).setAction(android.R.string.ok) {
                checkDeviceLocationSettingsAndGetLocationUpdates()
            }.show()
        }

    }

    locationSettingsResponseTask.addOnCompleteListener {
        if (it.isSuccessful) {
            locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 0, 0.0f, locationListener
            )

        }
    }
   

}

I am using the google services library to check Location setting if it was enabled or not
if the location is ON the location update request will be triggered

else it will ask the user to enable it and then trigger the location update request

if the services are not available nothing will happen and no location update will be requested

so I will try another way to check the location feature

Problem :

I have built an app using location detection to get the current location
I am using LocationManager and LocationLiastener

the app works fine but when I tried to run it on advice without android play service it won’t get the current Location and show the following dialog
enter image description here

this is the app link on Github
https://github.com/mostafa-n3ma/Pcm-helper1.0

Comments

Comment posted by No, it’s not

No, it’s not

Comment posted by مصطفى نعمه

I am using it when I check whether the location settings are enabled or not by calling LocationRequest from that library so whenever I run it on a device with no google services the the Location Update request is not triggered I will use a different ways to check Location settings thanks…

READ  [FIXED] android - Dagger 2: error: [ComponentProcessor:MiscError] circular dependency with generated code
Powered by Inline Related Posts

Comment posted by مصطفى نعمه

sorry I am using the library when I check the Location Settings if the location is enabled or not and I will direct the user to enable it in the method checkDeviceLocationSettingsAndGetLocationUpdates() in the fragment that deals with current Location

Comment posted by here

See

Android Tags:android, currentlocation, google-play-services

Post navigation

Previous Post: [FIXED] android – W/Firestore: (24.1.2) [CustomClassMapper]: No setter/field for about found on class
Next Post: [FIXED] android – FusedLocationProviderClient and LocationCallback() object queries

Related Posts

[FIXED] android – Issue with sealed interface type safety inside when – Kotlin Android
[FIXED] android – How to investigate Xamarin/libmonosgen-2.0.so native crash? Android
[FIXED] java – how do i use a API from rapid code in android app using volley with keys Android
[FIXED] java – Can’t launch activity from ADB shell Android
[FIXED] android – Google Fit api does not track data Android
[FIXED] java – android studio disable days from date picker Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What color are dead flea eggs?
  • What is Indiana vine?
  • What’s the downside of a Chromebook?
  • Is phosphide the same as phosphorus?
  • Why do you need an S bend?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme