error: package PermissionUtils does not exist





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I want to find the current location of the user through my app and I copied the source code from Github and I don't know it does not give me any error but this one.
Here's my code with all the libraries in case you think I have missed a library.



import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

public class location extends AppCompatActivity
implements
OnMyLocationButtonClickListener,
OnMapReadyCallback,
ActivityCompat.OnRequestPermissionsResultCallback {

/**
* Request code for location permission request.
*
* @see #onRequestPermissionsResult(int, String, int)
*/
private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

/**
* Flag indicating whether a requested permission has been denied after returning in
* {@link #onRequestPermissionsResult(int, String, int)}.
*/
private boolean mPermissionDenied = false;

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location);

SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap map) {
mMap = map;

mMap.setOnMyLocationButtonClickListener(this);
enableMyLocation();
}

/**
* Enables the My Location layer if the fine location permission has been granted.
*/
private void enableMyLocation() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Permission to access the location is missing.
PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
Manifest.permission.ACCESS_FINE_LOCATION, true);
} else if (mMap != null) {
// Access to the location has been granted to the app.
mMap.setMyLocationEnabled(true);
}
}

@Override
public boolean onMyLocationButtonClick() {
Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
// Return false so that we don't consume the event and the default behavior still occurs
// (the camera animates to the user's current position).
return false;
}


@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions,
@NonNull int grantResults) {
if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
return;
}

if (PermissionUtils.isPermissionGranted(permissions, grantResults,
Manifest.permission.ACCESS_FINE_LOCATION)) {
// Enable the my location layer if the permission has been granted.
enableMyLocation();
} else {
// Display the missing permission error dialog when the fragments resume.
mPermissionDenied = true;
}
}

@Override
protected void onResumeFragments() {
super.onResumeFragments();
if (mPermissionDenied) {
// Permission was not granted, display error dialog.
showMissingPermissionError();
mPermissionDenied = false;
}
}

/**
* Displays a dialog with error message explaining that the location permission is missing.
*/
private void showMissingPermissionError() {
PermissionUtils.PermissionDeniedDialog
.newInstance(true).show(getSupportFragmentManager(), "dialog");
}

}









share|improve this question































    1















    I want to find the current location of the user through my app and I copied the source code from Github and I don't know it does not give me any error but this one.
    Here's my code with all the libraries in case you think I have missed a library.



    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
    import com.google.android.gms.maps.OnMapReadyCallback;
    import com.google.android.gms.maps.SupportMapFragment;

    import android.Manifest;
    import android.content.pm.PackageManager;
    import android.os.Bundle;
    import android.support.annotation.NonNull;
    import android.support.v4.app.ActivityCompat;
    import android.support.v4.content.ContextCompat;
    import android.support.v7.app.AppCompatActivity;
    import android.widget.Toast;

    public class location extends AppCompatActivity
    implements
    OnMyLocationButtonClickListener,
    OnMapReadyCallback,
    ActivityCompat.OnRequestPermissionsResultCallback {

    /**
    * Request code for location permission request.
    *
    * @see #onRequestPermissionsResult(int, String, int)
    */
    private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

    /**
    * Flag indicating whether a requested permission has been denied after returning in
    * {@link #onRequestPermissionsResult(int, String, int)}.
    */
    private boolean mPermissionDenied = false;

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_location);

    SupportMapFragment mapFragment =
    (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap map) {
    mMap = map;

    mMap.setOnMyLocationButtonClickListener(this);
    enableMyLocation();
    }

    /**
    * Enables the My Location layer if the fine location permission has been granted.
    */
    private void enableMyLocation() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
    != PackageManager.PERMISSION_GRANTED) {
    // Permission to access the location is missing.
    PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
    Manifest.permission.ACCESS_FINE_LOCATION, true);
    } else if (mMap != null) {
    // Access to the location has been granted to the app.
    mMap.setMyLocationEnabled(true);
    }
    }

    @Override
    public boolean onMyLocationButtonClick() {
    Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
    // Return false so that we don't consume the event and the default behavior still occurs
    // (the camera animates to the user's current position).
    return false;
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions,
    @NonNull int grantResults) {
    if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
    return;
    }

    if (PermissionUtils.isPermissionGranted(permissions, grantResults,
    Manifest.permission.ACCESS_FINE_LOCATION)) {
    // Enable the my location layer if the permission has been granted.
    enableMyLocation();
    } else {
    // Display the missing permission error dialog when the fragments resume.
    mPermissionDenied = true;
    }
    }

    @Override
    protected void onResumeFragments() {
    super.onResumeFragments();
    if (mPermissionDenied) {
    // Permission was not granted, display error dialog.
    showMissingPermissionError();
    mPermissionDenied = false;
    }
    }

    /**
    * Displays a dialog with error message explaining that the location permission is missing.
    */
    private void showMissingPermissionError() {
    PermissionUtils.PermissionDeniedDialog
    .newInstance(true).show(getSupportFragmentManager(), "dialog");
    }

    }









    share|improve this question



























      1












      1








      1


      0






      I want to find the current location of the user through my app and I copied the source code from Github and I don't know it does not give me any error but this one.
      Here's my code with all the libraries in case you think I have missed a library.



      import com.google.android.gms.maps.GoogleMap;
      import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
      import com.google.android.gms.maps.OnMapReadyCallback;
      import com.google.android.gms.maps.SupportMapFragment;

      import android.Manifest;
      import android.content.pm.PackageManager;
      import android.os.Bundle;
      import android.support.annotation.NonNull;
      import android.support.v4.app.ActivityCompat;
      import android.support.v4.content.ContextCompat;
      import android.support.v7.app.AppCompatActivity;
      import android.widget.Toast;

      public class location extends AppCompatActivity
      implements
      OnMyLocationButtonClickListener,
      OnMapReadyCallback,
      ActivityCompat.OnRequestPermissionsResultCallback {

      /**
      * Request code for location permission request.
      *
      * @see #onRequestPermissionsResult(int, String, int)
      */
      private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

      /**
      * Flag indicating whether a requested permission has been denied after returning in
      * {@link #onRequestPermissionsResult(int, String, int)}.
      */
      private boolean mPermissionDenied = false;

      private GoogleMap mMap;

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_location);

      SupportMapFragment mapFragment =
      (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
      }

      @Override
      public void onMapReady(GoogleMap map) {
      mMap = map;

      mMap.setOnMyLocationButtonClickListener(this);
      enableMyLocation();
      }

      /**
      * Enables the My Location layer if the fine location permission has been granted.
      */
      private void enableMyLocation() {
      if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
      != PackageManager.PERMISSION_GRANTED) {
      // Permission to access the location is missing.
      PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
      Manifest.permission.ACCESS_FINE_LOCATION, true);
      } else if (mMap != null) {
      // Access to the location has been granted to the app.
      mMap.setMyLocationEnabled(true);
      }
      }

      @Override
      public boolean onMyLocationButtonClick() {
      Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
      // Return false so that we don't consume the event and the default behavior still occurs
      // (the camera animates to the user's current position).
      return false;
      }


      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String permissions,
      @NonNull int grantResults) {
      if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
      return;
      }

      if (PermissionUtils.isPermissionGranted(permissions, grantResults,
      Manifest.permission.ACCESS_FINE_LOCATION)) {
      // Enable the my location layer if the permission has been granted.
      enableMyLocation();
      } else {
      // Display the missing permission error dialog when the fragments resume.
      mPermissionDenied = true;
      }
      }

      @Override
      protected void onResumeFragments() {
      super.onResumeFragments();
      if (mPermissionDenied) {
      // Permission was not granted, display error dialog.
      showMissingPermissionError();
      mPermissionDenied = false;
      }
      }

      /**
      * Displays a dialog with error message explaining that the location permission is missing.
      */
      private void showMissingPermissionError() {
      PermissionUtils.PermissionDeniedDialog
      .newInstance(true).show(getSupportFragmentManager(), "dialog");
      }

      }









      share|improve this question
















      I want to find the current location of the user through my app and I copied the source code from Github and I don't know it does not give me any error but this one.
      Here's my code with all the libraries in case you think I have missed a library.



      import com.google.android.gms.maps.GoogleMap;
      import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
      import com.google.android.gms.maps.OnMapReadyCallback;
      import com.google.android.gms.maps.SupportMapFragment;

      import android.Manifest;
      import android.content.pm.PackageManager;
      import android.os.Bundle;
      import android.support.annotation.NonNull;
      import android.support.v4.app.ActivityCompat;
      import android.support.v4.content.ContextCompat;
      import android.support.v7.app.AppCompatActivity;
      import android.widget.Toast;

      public class location extends AppCompatActivity
      implements
      OnMyLocationButtonClickListener,
      OnMapReadyCallback,
      ActivityCompat.OnRequestPermissionsResultCallback {

      /**
      * Request code for location permission request.
      *
      * @see #onRequestPermissionsResult(int, String, int)
      */
      private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

      /**
      * Flag indicating whether a requested permission has been denied after returning in
      * {@link #onRequestPermissionsResult(int, String, int)}.
      */
      private boolean mPermissionDenied = false;

      private GoogleMap mMap;

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_location);

      SupportMapFragment mapFragment =
      (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
      }

      @Override
      public void onMapReady(GoogleMap map) {
      mMap = map;

      mMap.setOnMyLocationButtonClickListener(this);
      enableMyLocation();
      }

      /**
      * Enables the My Location layer if the fine location permission has been granted.
      */
      private void enableMyLocation() {
      if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
      != PackageManager.PERMISSION_GRANTED) {
      // Permission to access the location is missing.
      PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
      Manifest.permission.ACCESS_FINE_LOCATION, true);
      } else if (mMap != null) {
      // Access to the location has been granted to the app.
      mMap.setMyLocationEnabled(true);
      }
      }

      @Override
      public boolean onMyLocationButtonClick() {
      Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
      // Return false so that we don't consume the event and the default behavior still occurs
      // (the camera animates to the user's current position).
      return false;
      }


      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String permissions,
      @NonNull int grantResults) {
      if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
      return;
      }

      if (PermissionUtils.isPermissionGranted(permissions, grantResults,
      Manifest.permission.ACCESS_FINE_LOCATION)) {
      // Enable the my location layer if the permission has been granted.
      enableMyLocation();
      } else {
      // Display the missing permission error dialog when the fragments resume.
      mPermissionDenied = true;
      }
      }

      @Override
      protected void onResumeFragments() {
      super.onResumeFragments();
      if (mPermissionDenied) {
      // Permission was not granted, display error dialog.
      showMissingPermissionError();
      mPermissionDenied = false;
      }
      }

      /**
      * Displays a dialog with error message explaining that the location permission is missing.
      */
      private void showMissingPermissionError() {
      PermissionUtils.PermissionDeniedDialog
      .newInstance(true).show(getSupportFragmentManager(), "dialog");
      }

      }






      android google-maps location






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 5 '16 at 15:37









      Laurel

      4,821102239




      4,821102239










      asked Feb 20 '16 at 10:11









      user3149023user3149023

      2416




      2416
























          1 Answer
          1






          active

          oldest

          votes


















          1














          This is because your sample code is part of a tutorial and is still missing a helper class.



          Here is the PermissionUtils code located in GitHub in the same project.






          share|improve this answer





















          • 1





            That GitHub link is broken right now...

            – SebasSBM
            Sep 25 '18 at 13:20












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35521756%2ferror-package-permissionutils-does-not-exist%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This is because your sample code is part of a tutorial and is still missing a helper class.



          Here is the PermissionUtils code located in GitHub in the same project.






          share|improve this answer





















          • 1





            That GitHub link is broken right now...

            – SebasSBM
            Sep 25 '18 at 13:20
















          1














          This is because your sample code is part of a tutorial and is still missing a helper class.



          Here is the PermissionUtils code located in GitHub in the same project.






          share|improve this answer





















          • 1





            That GitHub link is broken right now...

            – SebasSBM
            Sep 25 '18 at 13:20














          1












          1








          1







          This is because your sample code is part of a tutorial and is still missing a helper class.



          Here is the PermissionUtils code located in GitHub in the same project.






          share|improve this answer















          This is because your sample code is part of a tutorial and is still missing a helper class.



          Here is the PermissionUtils code located in GitHub in the same project.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 8 at 9:59









          Sebastian

          1,7781425




          1,7781425










          answered Feb 26 '16 at 22:24









          rwvaldiviarwvaldivia

          124212




          124212








          • 1





            That GitHub link is broken right now...

            – SebasSBM
            Sep 25 '18 at 13:20














          • 1





            That GitHub link is broken right now...

            – SebasSBM
            Sep 25 '18 at 13:20








          1




          1





          That GitHub link is broken right now...

          – SebasSBM
          Sep 25 '18 at 13:20





          That GitHub link is broken right now...

          – SebasSBM
          Sep 25 '18 at 13:20




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35521756%2ferror-package-permissionutils-does-not-exist%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine