Tutorial Get Current Latitude & Longitude Android Studio 2017

Android

Video is ready, Click Here to View ×


Full coding here :
http://activeterium.com/86ai
.
If you are willing to donate, my paypal address is firasqoid21@gmail.com – Even amounts as small as a dollar are big helps everyone, so thank you!
.
.

30 thoughts on “Tutorial Get Current Latitude & Longitude Android Studio 2017

  1. Dont ans it worked u are the best the issue was i was using wifi but wen i connected to my cellular data it worked there and then thanks.. can u make tutorials that converts it to location names

  2. error occur, plz help me…
    Caused by: java.lang.InstantiationException: java.lang.Class<com.example.aa.latitude.MainActivity> cannot be instantiated
    at java.lang.Class.newInstance(Native Method)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1072)

  3. the exact problem here is
    1. doesn't work from computer
    2. open location or GPS to get the longitude and latitude
    3. it works from cellphone when generated.

    that's cool, thanks a lot

  4. Plz help me … location is null… please check it…

    void getLocation()
    {
    if(ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)!=
    PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,Manifest.permission.ACCESS_COARSE_LOCATION)
    !=PackageManager.PERMISSION_GRANTED)
    {
    ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION},REQUEST_LOCATION);

    }
    else

    {

    Location location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

    if(location!=null)
    {
    double lotti=location.getLatitude();
    double lotgi=location.getLongitude();

    ((EditText)findViewById(R.id.etLocationLat)).setText("Latitude "+lotti);
    ((EditText)findViewById(R.id.etLocationLong)).setText("Longitude "+lotgi);
    }
    else
    {
    ((EditText)findViewById(R.id.etLocationLat)).setText("Unable to find location");
    ((EditText)findViewById(R.id.etLocationLong)).setText("Unable to find location");

    }
    }

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,@NonNull int[] grantResults)
    {
    super.onRequestPermissionsResult(requestCode,permissions,grantResults);

    switch (requestCode)
    {
    case REQUEST_LOCATION:
    getLocation();
    break;

    }

    }

  5. not working for me , please helpe me
    "
    public void getLocation(){
    if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
    && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){
    ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
    }else{
    Location location = locationManager.getLastKnownLocation(locationManager.NETWORK_PROVIDER);
    if(location != null){
    double latitude = location.getLatitude();
    double longitude = location.getLongitude();
    Toast.makeText(this, " Latitude : "+latitude, Toast.LENGTH_SHORT).show();
    }else {
    Toast.makeText(this, " latitude not found ", Toast.LENGTH_SHORT).show();
    }
    }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode){
    case REQUEST_LOCATION :
    getLocation();
    break;
    }
    }

    "

Leave a Reply

Your email address will not be published. Required fields are marked *