Blog Directory logo  Blog Directory
  •  Login
  • Register
  • Submit a Blog in Featured for only $10 with PaypalFeatured BlogsBlog Listing
    Member - { Blog Details }

    hero image

    blog address: http://findnerd.com/list/view/New-Location-Dialog-from-Android-Settings-API/7195/

    keywords: Android, Current Location, Custom Dialog

    member since: Dec 4, 2015 | Viewed: 181

    How to Enable New Location Dialog from Android Settings API

    Category: Technology

    Enable a system location dialog ,asking user that app needs to find the current location This dialog is from Android Settings API. Check the source code below. YodmG public class LocationData implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { Context _context; Location latKnowLocation; static GoogleApiClient mGoogleApiClient; LocationInterface loIn; StartAct startAct; PendingResult result; //Location requests LocationRequest locationRequest = LocationRequest.create() .setInterval(10 * 60 * 1000) // every 10 minutes .setExpirationDuration(10 * 1000) // After 10 seconds .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder; public LocationData(Context con) { _context = con; mGoogleApiClient = new GoogleApiClient.Builder(con.getApplicationContext()) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); mGoogleApiClient.connect(); //initialize the builder and add location request paramenter like HIGH Aurracy builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); // set builder to always true (Shows the dialog after never operation too) builder.setAlwaysShow(true); // Then check whether current location settings are satisfied: result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build()); } // call back for other class public void callbacksResults() { // call backs for lcoation status result.setResultCallback(new ResultCallback() { @Override public void onResult(LocationSettingsResult result) { final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: // All location settings are satisfied. The client can initialize location // requests here. if(mGoogleApiClient.isConnected()) { latKnowLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); } break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: // Location settings are not satisfied. But could be fixed by showing the user // a dialog. try { status.startResolutionForResult((Activity) _context, Constants.REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings are not satisfied. However, we have no way to fix the // settings so we won't show the dialog. break; } } }); } // call back for other class public void callbacksResultsSplash() { // call backs for lcoation status result.setResultCallback(new ResultCallback() { @Override public void onResult(LocationSettingsResult result) { final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: ....... Read full blog at -http://findnerd.com/list/view/New-Location-Dialog-from-Android-Settings-API/7195/



    { More Related Blogs }
    © 2025, Blog Directory
     | 
    Google Pagerank: 
    PRchecker.info
     | 
    Support
               Submit a Blog
               Submit a Blog
    Collaboration software for team 

    Technology

    Collaboration software for tea...


    Aug 21, 2023
    CES 2016: Top 5 Expectations

    Technology

    CES 2016: Top 5 Expectations...


    Dec 28, 2015
    فيس سوفت | تحميل أفضل تطبيقات الاندرويد و الالعاب وسامسونج جالكسي اس 4 واس 3 وجالكسي نوت3 و تاب

    Technology

    فيس سوفت | تحميل أفضل تطبيقات ...


    Jun 9, 2014
    data recovery services

    Technology

    data recovery services...


    May 28, 2015
    A Detailed Guide To Metaverse Tourism and Hospitality

    Technology

    A Detailed Guide To Metaverse ...


    Sep 21, 2022
    How To Fix Norton Antivirus Will not Open?

    Technology

    How To Fix Norton Antivirus Wi...


    Jul 20, 2021