How to get device last location (using GPS/ Network) without using Map Layout in your Android App?

preview_player
Показать описание
This video shows how to implement the FusedLocationProviderClient from the Google's play-services-location to get the last location of the device.

In this approach it need not to use the google maps layout or use the Google Maps API key required to get the google map information.

This approach uses the google's play services (location) to get the regular update of the location as and when recorded by the device.

This concept is useful when one needs to get the location information implicitly and use it in their main application as an input data.

The complete source code of this tutorial is shared at the below link:

The java code is shared below also for reference:

import android.Manifest;

public class MainActivity extends AppCompatActivity {

private TextView textView;

private String stringLatitude = "0.0";
private String stringLongitude = "0.0";

private FusedLocationProviderClient fusedLocationProviderClient;

@Override
protected void onCreate(Bundle savedInstanceState) {

}

public void buttonGetLocation(View view) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}

@Override
public void onSuccess(Location location) {

if (location!=null){
}

}
});
}
}
Рекомендации по теме
Комментарии
Автор

Thankyou So Much for Each And Every Tutorials. Your each video is Helpful.

rajmistry
Автор

Hi nice video.
The first step is verify that GPS is already Activated right?

rogerccaqp
Автор

Can you help me please. I'm getting location null

redwansharafatkabir
join shbcf.ru