best android developer ever . Big fan... keep it up bro
@cforge24116 жыл бұрын
i finished it just now, and YOU LITERALLY DE-MYSTIFIED the maps. thanks a lot Mitch
@JasonPurkiss7 жыл бұрын
I felt sorry for you with your previous video comment of having a broken keybored so have purchased your SQLlite course to help you in these hard times :)
@JasonPurkiss7 жыл бұрын
Interestingly the cost of your video's converted to English pounds comes to the price of a beer here in London, so enjoy :)
@codingwithmitch5 жыл бұрын
hahaha I just saw this now. Thanks Jason.
@tomislavemilov22475 жыл бұрын
So for the ones that say that they don't get location. This is happening, bacause in this video is used getLastLocation and that's the point of the fusedLocationClient, to use last known location, but in case that the divece is new or was restored to factory reset or there was not call for location from other app it will produce null. So just make a call to get the location and it will work. Great video btw :)
@aymanatef30145 жыл бұрын
i used locationManager and work fine too private void getLocalDevice() { LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); try { moveCamera(locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER), DEFAULT_CAMRA_ZOOM, "my place"); } catch (SecurityException e) { Log.d(TAG, "getLocalDevice: " + e.getMessage()); } }
@subodhrai75005 жыл бұрын
I want to be a programmer like u, sir, perfect sir, thanx for your uploading such a video its very helpful for me.
@casaurabhkhatri85456 жыл бұрын
You are Hero!!!!!! Explanation is brilliant!! Keep going.
@whogashaga5 жыл бұрын
Your course really help me a lot ! thanks
@udgardixit6145 жыл бұрын
Hey how do i ask for the user to turn on device location like the one Google Maps asks when you open it up and haven't turned on your device location..."To continue, turn on device location, which uses Google's location service."
@mimrankhan99746 жыл бұрын
its so simple but i dont know why you make it so difficult you are good programmer
@codingwithmitch6 жыл бұрын
what lol
@gabrielalmeida13866 жыл бұрын
we have a problem, the Play Store is asking for versions with the API 27+, but when I put it to compile for this API the code: "mMap.setMyLocation (true)" causes the application to crash. how to solve?
@hoseaochieng53556 жыл бұрын
You are such a gem! This is incredibly resourceful to me, gracias!
@cforge24116 жыл бұрын
just wow man thanks. if anyone haad any troubles, now dependencies are added in modules so //Play Services //Maps implementation 'com.google.android.gms:play-services-maps:15.0.1' //Play Services //Location implementation 'com.google.android.gms:play-services-location:15.0.1'
@stonks97555 жыл бұрын
after i added all the additional methods in this tutorial, the map doesnt even show, but the notification "Map is ready" appears. Is there a file that im missing? Or does it have anything to do with the Google API key?
@OneSpikedDrink4 жыл бұрын
Please tell me you found the fix. I have the same issue
@MuhammadBilal-ry5rb5 жыл бұрын
"FusedLocationProviderClient" is not import so how i can import this library and i also add all dependencies in build.gradle as well but i can't find any solution.
@barry007h5 жыл бұрын
Same here, Documentation doesnt help either
@ვაკოვარდიშვილი5 жыл бұрын
add dependency in build.gradle folder implementation 'com.google.android.gms:play-services-location:15.0.1'
@k3nyon7 жыл бұрын
Hey man, where is the new videos? Don't stop please, you help me so much. Thank you.
@MaciejRzemek6 жыл бұрын
I've seen that some of you got location on Googleplex! Any ideas how to fix that? ;)
@niclasb48607 жыл бұрын
I had an issue with the app crashing as soon as I opened the map. I solve the issue by updating build.gradle to a higher version (v.26).
@karaangmandirigma60956 жыл бұрын
howw ?
@abdelrahmanazab95154 жыл бұрын
???
@truthseeker117 жыл бұрын
Ok, so here is a little bit of a work around if you're getting the Null Pointer Exception for your location. Just have the user turn on their location when the app opens. So, in the MainActivity, within the if(isServicesOK()) statement, place the statusCheck() method after the init() function. And here are the two methods. They will show a dialog if location is off. Once turned on, the app should work. :) Source code below. Credits from this Stack Overflow question - stackoverflow.com/questions/25175522/how-to-enable-location-access-programmatically-in-android: public void statusCheck() { final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps(); } } private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Your GPS seems to be disabled, do you want to enable it?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); } Your onCreate method in the MainActivity class will look like this now: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(isServicesOK()) { init(); statusCheck(); //
@codingwithmitch7 жыл бұрын
Christopher Sheridan thanks
@pruthvikumar22586 жыл бұрын
Am getting following error after adding getDeviceLocationMethod(Pls help me as am new to android) : E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering Tried stack overflow,nothing worked.Running on android kitkat version
@maaryjoseph7306 жыл бұрын
lame but very important.. thanks christopher
@alricliew7146 жыл бұрын
Thanks. Christopher Sheridan
@soydevpro13235 жыл бұрын
Thanks guys!!!
@kirpalsinghsh2067 жыл бұрын
@MitchTabian The app crashes on my Samsung Note 3 when my GPS is turned off. Is there a way to display a message to turn on GPS to run the map or at least check if GPS is turned on
@jorgeoviedo7325 жыл бұрын
Hi Mitch, Thanks for the tutorial. Is what I was needing. Now I will need to know if is possible, how replace the blue dot in the User location for an Image or Icon. Thanks
@codingwithmitch5 жыл бұрын
Using a marker cluster. Watch my google maps 2018 course. I show you that
@jorgeoviedo7325 жыл бұрын
@@codingwithmitch This is my actual code after the video. ... import android.Manifest; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.Toast; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.BitmapDescriptorFactory; public class MiamiActivity extends AppCompatActivity implements OnMapReadyCallback { @Override public void onMapReady ( GoogleMap googleMap ) { Toast.makeText( this, "Map is Ready", Toast.LENGTH_SHORT ).show(); Log.d( TAG, "onMapReady: map is ready" ); mMap = googleMap; // Subway (2962 SW 8th) LatLng subway2962 = new LatLng(25.764590, -80.242120); mMap.setMapType( GoogleMap.MAP_TYPE_NORMAL ); mMap.addMarker(new MarkerOptions().position(subway2962).title("Subway")); // Moe’s Southwest Grill (Jackson Memorial) LatLng Moes_Southwest_Grill = new LatLng( 25.792320, -80.210830 ); mMap.addMarker( new MarkerOptions().position( Moes_Southwest_Grill ).title( "Moe’s Southwest Grill" ).icon( BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_VIOLET ) ) ); mMap.moveCamera( CameraUpdateFactory.newLatLng( Moes_Southwest_Grill ) ); // The Smoothie Shop (Brickell) LatLng The_Smoothie_Shop = new LatLng( 25.762160, -80.189110 ); mMap.addMarker( new MarkerOptions().position( The_Smoothie_Shop ).title( "The Smoothie Shop" ).icon( BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_VIOLET ) ) ); mMap.moveCamera( CameraUpdateFactory.newLatLng( The_Smoothie_Shop ) ); if (mLocationPermissionsGranted) { getDeviceLocation(); if (ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_COARSE_LOCATION ) != PackageManager.PERMISSION_GRANTED) { return; } mMap.setMyLocationEnabled( true ); } } private static final String TAG = "MapActivity"; private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION; private static final String COURSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION; private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234; private static final float DEFAULT_ZOOM = 15f; //vars private Boolean mLocationPermissionsGranted = false; private GoogleMap mMap; private FusedLocationProviderClient mFusedLocationProviderClient; @Override protected void onCreate ( @Nullable Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_miami ); getLocationPermission(); } private void getDeviceLocation () { Log.d( TAG, "getDeviceLocation: getting the devices current location" ); mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient( this ); try { if (mLocationPermissionsGranted) { final Task location = mFusedLocationProviderClient.getLastLocation(); location.addOnCompleteListener( new OnCompleteListener() { @Override public void onComplete ( @NonNull Task task ) { if (task.isSuccessful()) { Log.d( TAG, "onComplete: found location!" ); Location currentLocation = (Location) task.getResult(); moveCamera( new LatLng( currentLocation.getLatitude(), currentLocation.getLongitude() ), DEFAULT_ZOOM ); } else { Log.d( TAG, "onComplete: current location is null" ); Toast.makeText( MiamiActivity.this, "unable to get current location", Toast.LENGTH_SHORT ).show(); } } } ); } } catch (SecurityException e) { Log.e( TAG, "getDeviceLocation: SecurityException: " + e.getMessage() ); } } private void moveCamera ( LatLng latLng, float zoom ) { Log.d( TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude ); CameraPosition cameraPosition = new CameraPosition.Builder() .target(latLng) // Sets the center of the map to User Location View .zoom(15) // Sets the zoom .bearing(90) // Sets the orientation of the camera to east .tilt(30) // Sets the tilt of the camera to 30 degrees .build(); // Creates a CameraPosition from the builder mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); mMap.getUiSettings().setMyLocationButtonEnabled(true ); } private void initMap () { Log.d( TAG, "initMap: initializing map" ); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById( R.id.map ); mapFragment.getMapAsync( MiamiActivity.this ); } private void getLocationPermission () { Log.d( TAG, "getLocationPermission: getting location permissions" ); String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}; if (ContextCompat.checkSelfPermission( this.getApplicationContext(), FINE_LOCATION ) == PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission( this.getApplicationContext(), COURSE_LOCATION ) == PackageManager.PERMISSION_GRANTED) { mLocationPermissionsGranted = true; initMap(); } else { ActivityCompat.requestPermissions( this, permissions, LOCATION_PERMISSION_REQUEST_CODE ); } } else { ActivityCompat.requestPermissions( this, permissions, LOCATION_PERMISSION_REQUEST_CODE ); } } @Override public void onRequestPermissionsResult ( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults ) { Log.d( TAG, "onRequestPermissionsResult: called." ); mLocationPermissionsGranted = false; switch (requestCode) { case LOCATION_PERMISSION_REQUEST_CODE: { if (grantResults.length > 0) { for (int i = 0; i < grantResults.length; i++) { if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { mLocationPermissionsGranted = false; Log.d( TAG, "onRequestPermissionsResult: permission failed" ); return; } } Log.d( TAG, "onRequestPermissionsResult: permission granted" ); mLocationPermissionsGranted = true; //initialize our map initMap(); } } } } } I Just adapted your explanation to my necessities. Now What I want is replace the blue dot that is added by default in user location for an Icon like a "Car". Idea is when the user open the app, show the Car(Icon) and not the blue dot, where the user is located(actual location). Thanks.
@shaniashi99066 жыл бұрын
Hi Mitch, I use your code in my implementation, however, it seems that my current location is always at Googleplex, which is definitely incorrect. Do you have any idea why? Many Thanks!
@cforge24116 жыл бұрын
did you start with GoogleMaps Activity or Empty Activity? in either case, let me know
@shaniashi99066 жыл бұрын
Empty Activity with MapFragment. Thx
@cforge24116 жыл бұрын
that seems weird. If the issue still exists, let me have a look at you code.
@Darkvan16616 жыл бұрын
mine too - anyway to solve this problem?
@Darkvan16616 жыл бұрын
@@cforge2411 I get the same error too - anyway to solve thisss. HELP
@keshavtangri5715 жыл бұрын
Hi Mitch, just like we added Latitude and Longitude in the Move camera function, can we add custom latitude longitude points and just dont move our camera there ?? Suppose I have some custom Lat and Long positions and what i want is that my current location is shown on the map , just like we did in this video and on the same map I should also see my custom latitude and Longitude markers... Can you help me with that ??? Anyone else who know how to do that can also comment and guide me through this. Any help is Welcome, Thanks in Advance !
@asarephilip7 жыл бұрын
Thanks so much... I was having difficulties implementing the FusedLocationProviderClient but i just find my way out after watching this tutorial. Big Ups :)
@ADC31314 жыл бұрын
when I try implementing it, it says cannot resolve symbol can you help with this?
@faxmodem23974 жыл бұрын
How many goals do I have in common with specific locations so that I can see my location online with goals? Is this possible? Can you help?
@funaustralia65174 жыл бұрын
hi Mitch; if I using map in fragment, how can used initMap()? this is my coed private void initMap(){ Log.d(TAG,"initMap: initializing map"); SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(NewMapFragment.this); } and public class NewMapFragment extends Fragment implements OnMapReadyCallback { but, when I using this coed private void getLocationPermission(){ Log.d(TAG,"getLocationPermission: getting location permissions"); String[] permission = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}; if(ContextCompat.checkSelfPermission(getActivity().getApplicationContext(),FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){ if(ContextCompat.checkSelfPermission(getActivity().getApplicationContext(),COURSE_LOCATION) == PackageManager.PERMISSION_GRANTED){ mLocationPermissionsGranted = true; initMap(); } else { ActivityCompat.requestPermissions(getActivity(),permission, LOCATION_PERMISSION_REQUEST_CODE); } }else { ActivityCompat.requestPermissions(getActivity(),permission, LOCATION_PERMISSION_REQUEST_CODE); } } and when I go to the newMapFragment, I will get NPE error java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference at com.stanley.ifunpot.ui.NewMapFragment.initMap(NewMapFragment.java:113) so I need to call initMap() in getLocationPermission? or not? Because I cannot get my device location
@funaustralia65174 жыл бұрын
Solve it. in oncreateview using this code SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this);
@shivamsompura22346 жыл бұрын
location returned null !!!
@abirabed61934 жыл бұрын
i had the same problem change you google map api key
@l504064 жыл бұрын
Make sure that the device location is on that was my problem.
@pruthvikumar22586 жыл бұрын
Am getting following error after adding getDeviceLocationMethod(Pls help me as am new to android) : E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering Tried stack overflow,nothing worked.Running on android kitkat version
@shaon69966 жыл бұрын
Your procedure does not work in Android API level 24 :( I can't get current device location in API 24 but it works all devices below API 24. 😒😖
@saqfinaqi24246 жыл бұрын
you need to ask runtime permission to access user location
@Darkvan16616 жыл бұрын
I can't seem to get device location - anyways to resolve this. the codes are the same as the provided source ode, so i don't seem to get the problem. HELP PLSS
@tsurugikyousuke38076 жыл бұрын
Map pointer is showing but i need to scroll to see my pointer. Map is showing somewhere else. Help?
@MCFatDad19736 жыл бұрын
Could you add a video to save the state for when the devices orientation has changed. thanks. Your videos are great.
@abdulwahid_mohammed7 жыл бұрын
Thanks a lot we are waiting to the next .
@mixknowledge64206 жыл бұрын
FusedLocationproviderClient is not available in android studio??
@mixknowledge64206 жыл бұрын
leave it. thanks
@muhammadziaullah46216 жыл бұрын
@@mixknowledge6420 same problem
@muhammadziaullah46216 жыл бұрын
@@mixknowledge6420 any suggestion??
@alphazero06 жыл бұрын
@@muhammadziaullah4621 add this in your depedencies implementation "com.google.android.gms:play-services-location:15.0.1"
@hgmusicse98856 жыл бұрын
Hi Mitch! I like your tutorials! I got a problem, after my latest update patch of Android Studio, my app crasches and I get this error msg; C:\Users\Admin\AndroidStudioProjects\Where_Am_I\app\src\main\java\com\example\admin\where_am_i\MapsActivity.java uses unchecked or unsafe operations. This line; location.addOnCompleteListener(new OnCompleteListener() is unchecked in the according to android studio. How do I solve this? I have searched the net, but find nothing to help me. Pls Help!
@chessamaulana37676 жыл бұрын
how to autotext method Log.d like you did in the video?
@Peesashit2845 жыл бұрын
Hey Mitch, I my project was able to compile perfectly up untill this point, but I noticed that maps was incorrectly showing my location in GooglePlex, California. Any suggestions? I guessed there was something wrong with my getLocation method. I've checked and everything looks alright. Great course btw, very helpful!
@ВадимА-й8ф5 жыл бұрын
do not forget to add this line to your code: .... if (currentLocation != null) { moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()), DEFAULT_ZOOM, "My Location"); }; .... if you don't, you will have NPУ when GPS is off
@ВадимА-й8ф5 жыл бұрын
NPE*
@himanshunegi32165 жыл бұрын
I am getting null object reference on getMapAsync(), how should I solve this problem Please Help. I am a newbie. Thank You
@olukayodepaul70705 жыл бұрын
is it possible to update sqlite room with update location instead of firebase
@jurasv25 жыл бұрын
Hi, how can I check after all is localization is turn on, on the device?
@harithhusni87886 жыл бұрын
hye mitch, where is the center button that can get our location ? i can't find the center button but my current location is detected. Hope u can help me.
@guilhermecalvi65685 жыл бұрын
Your tutorial is perfect, i love it.
@swathysoundar52766 жыл бұрын
hey I followed through your video but I'm not getting the device location help me out thanks
@halaalothman35746 жыл бұрын
me too
@lotemmimon83856 жыл бұрын
me too
@rossglover73906 жыл бұрын
Any luck with this?
@rossglover73906 жыл бұрын
I have no errors but the location is simply not shown?
@ahmdshetya16046 жыл бұрын
may be deprecated :[
@tamiroffen10796 жыл бұрын
I'm not getting the permissions pop-ups. Is this a problem? btw i'm still able to load the map.
@unicorngirlclemenz316 жыл бұрын
Hey mich I get this error "Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference"
@kutubekkylychbekov26346 жыл бұрын
why if my location disabled on my device app doesn't request to enable it? how can i make it?
@rabiunislam93026 жыл бұрын
nice explanation and the flow of code
@fabricedesign98356 жыл бұрын
Hi, I'm french and when I run the app, my location appear near San José and not in france. Do you know why?
@cforge24116 жыл бұрын
can you show your onMapReady method? i've a feeling there's the problem
@aleksanije59744 жыл бұрын
@@cforge2411 I am getting exact same thig, map is showing that im in San Jose.
@robelhaftom49982 жыл бұрын
hey Mitch, first of all thank you for providing us this type of tutorial. I was developing the same GPS app and I used your tutor as a guide but in this part my device toasts ' unable to get current location ' message and I don't know how to fix it. please show me how to fix it
@maqumo18364 жыл бұрын
Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.moveCamera(com.google.android.gms.maps.CameraUpdate)' on a null object reference at com.example.geo_snap.MapsActivity.movecamera(MapsActivity.java:212) this error is coming only first time when i open.. please help me
@hiteshgarg63037 жыл бұрын
Can you tell me how to do realtime tracking of another person having our app?
@kundandalmia25913 жыл бұрын
It returns GooglePlex for me when I getlastLocation() on emulator. Please help
@ShauryVerma6 жыл бұрын
This code without error run on Emulator and get random location but same code I will debug my cell phone then fire error on calling to moveCamera function why?
@user-rd1dm2dt9x6 жыл бұрын
when I get latitude and longitude using location variable I'm getting error.
@arminlaghaee39106 жыл бұрын
Tnx, for the video. When I want to find my current location, incited of showing me Burnaby,BC (where I live), it shows me Googlplex in USA. Idont know why? Is it because I am using the emulator not a phone.
@codingwithmitch6 жыл бұрын
Yes that would be my guess. I live in Langley, BC. Are you a student at UBC?
@cristiantamas92966 жыл бұрын
same here, on the phone is working, on the emulator showing mitch's location.
@kgpsoftminds25277 жыл бұрын
Thank you so much for the videos, they have been helping me so much. i started by buying your course. i want to ask how i could use this in a child fragment of a parent fragment found in a drawer. That's the problem am facing. if u could help me with some tips on how to work around. Thanks
@I_Nasir_Khattak6 жыл бұрын
ava.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference ............. what is the error please explain
@zohaibshehzad50395 жыл бұрын
Hi Mitch! Does the location move when you move in any location ? Does it gives us real time location ? Waiting for your reply Thanks in Advance.
@siminam.michile46485 жыл бұрын
Idk if it helps but for me the real location finally worked when I added the 2nd else here (video 4, min 11:52) private void getLocationPermission(){ Log.d(TAG, "getLocationPermission: getting location permission"); String[] permission = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}; if(ContextCompat.checkSelfPermission(this.getApplicationContext(), FINE_LOC) == PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(this.getApplicationContext(), COARSE_LOC) == PackageManager.PERMISSION_GRANTED) { mLocatikonPermissionGranted = true; //1 initMap(); } else { ActivityCompat.requestPermissions(this, permission, LOCATION_PERM_REQUEST_CODE); } } // this one------------------------------------------------- else { ActivityCompat.requestPermissions(this, permission, LOCATION_PERM_REQUEST_CODE); } //---------------------------------------------- }
@zohaibshehzad50395 жыл бұрын
@@siminam.michile4648 Thanks 😊
@shababkm18037 жыл бұрын
You are a brilliant person, These tutorials are very useful for anyone who does not know about Android. I don't know anything about android. You taught me everything Thank you... You have to do me a favor. The Instagram application you have created makes it clear that all users will have to upload all user-uploaded photos instead of the following system. Can you please help me out? Can you please tell me the code of this method?
@chrisadikaram6 жыл бұрын
The mMap.setMyLocationEnabled(true); function does not seem to be setting the blue dot on the map
@shelle.y5 жыл бұрын
Comment out the line beneath it, I had the same problem and that's what worked for me!
@aneeshpv26267 жыл бұрын
Thanks a lot for this tutorial. Can you please explain how to receive location updates?
@Frankestine-id2wt6 жыл бұрын
onMapReady is not called and setLocationEnabled also
@pegahes10796 жыл бұрын
if you get null location just add this line to your manifest
@udithasampath49916 жыл бұрын
how can get selected place timezone ??? please suggest any calculation or method...
@nikkobanquil2186 жыл бұрын
Hi sir, im getting "uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details." error. I dont even have a raw type arraylist here. Can you help me about this?
@chanukadesilva89206 жыл бұрын
Create the Task as Task locationResult = mFusedLocationProviderClient.getLastLocation(); Then recreate the onCompleteListener
@anashamdi89926 жыл бұрын
i have a problem icon not show when write mMap.getUiSetting().setMylocationButtonEnable(true)
@chrisadikaram6 жыл бұрын
I'm having a similar issue
@rahul88205 жыл бұрын
sir getLatitude() is pointing to null reference exception. whats the way out for this
@rivodwiyulianto56424 жыл бұрын
im also get this error do u already solve it? pls tell me
@ibrahemgamal31184 жыл бұрын
@@rivodwiyulianto5642 @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { if (task.getResult()!=null) { Location location = (Location) task.getResult(); MoveCamera(new LatLng(location.getLatitude(), location.getLongitude()), 15f); }else { LocationRequest locationRequest=LocationRequest.create(); locationRequest.setInterval(1000); locationRequest.setFastestInterval(5000); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationCallback locationCallback=new LocationCallback(){ @Override public void onLocationResult(LocationResult locationResult) { if (locationResult==null){ return; }else { super.onLocationResult(locationResult); Location mlocation = locationResult.getLastLocation(); MoveCamera(new LatLng(mlocation.getLatitude(), mlocation.getLongitude()), 15f); } } }; fusedLocationProviderClient.requestLocationUpdates(locationRequest,locationCallback,null); look at this after getting task result check if it is null
@user_ahfvppkjb4 жыл бұрын
I did everything same like you but location is always returned null, i checked the app's permission settings and it had the permission to access location enabled so what could be the problem. I appreciate your help.
@abdelrahmanazab95154 жыл бұрын
You solve it?
@reiscollections016 жыл бұрын
Very Nice! Well explained! It helps me a lot. May i request if you could create a tutorial too on "Street View" . It would be great if you will make one :D !
@codingwithmitch6 жыл бұрын
I'll add it to the list lol
@scoutility6 жыл бұрын
IF YOU ARE HAVING TROUBLE WITH FUSEDLOCATIONSERVICEPROVIDER: add the following to your build.gradle: implementation 'com.google.android.gms:play-services-location:15.0.1' make sure the version is the same as the other google play services SDKs you have implemented in gradle ie. all must be 15.0.1 in my case. Sync and you're done :) hope that helps anyone bc I had the same problem.
@irfaanpermana85246 жыл бұрын
thanks bro :)
@rozikhan26047 жыл бұрын
Love your courses. Can u start a course on Beacons?
@abimekonnen82314 жыл бұрын
u doing great God bless u
@bagaskaracahya72616 жыл бұрын
Hi! thanks for the tutorial u made, i just tried your code and i just found out there is an error in my code, its said that "error: cannot find symbol method getLatitude()" and "error: cannot find symbol method getLongitude()". how should i do to make this work ? hope you answer it, thanks!
@bagaskaracahya72616 жыл бұрын
nevermind, found it!
@abdullahishtiaq65374 жыл бұрын
@@bagaskaracahya7261 plz i need solution of this error ...am still getting null location
@varshasrinivasan13407 жыл бұрын
The app shows me only the map. It doesn't automatically show me the location neither is the marker shown. Please help
@dipesh75127 жыл бұрын
Instead of Manually writing mapReady function create a new activity and select google Map activity ..Andriod studio will automatically create the code shown in part 3 of this series..which shows the marker as well
@cforge24116 жыл бұрын
can you show your logcat?
@officialtopchefbeats6 жыл бұрын
how to you get the FusedLocationProviderClient? Mine is RED. Everything else is fine but for some reason, the FLPC won't work or react correctly. Help please. Thanks
@cristiantamas92966 жыл бұрын
you need this in your gradle: implementation 'com.google.android.gms:play-services-location:11.8.0'
@officialtopchefbeats6 жыл бұрын
Ah yeah, its been living in my gradle since the beginning of the project. It may be my laptop operating system, I just may need an upgrade
@saracastillo44956 жыл бұрын
Hi! thanks for your video. It's great! but I have an issue.. I followed through your video and at beginning it worked, but now I'm not getting the device location (the blue dot dissapeared and the GPS icon isn't getting me back to my position) Coul anybody PLEASE help me out !?? thanks
@bilalyousaf69025 жыл бұрын
hello sir I followed through your videos ...but I'm not getting the device location help me out please sir, thanks
@jayceewu84795 жыл бұрын
SAme! i keep getting a null error
@markdelrosario42316 жыл бұрын
Hello can someone know how to set m my default location here in philippines?
@wissemrezki60724 жыл бұрын
How to change location on the maps longitude and latitude ?
@krishnagandhi42966 жыл бұрын
How to make maps like uber? Can you help me out with it. Real Time Location
@bilalyousaf69025 жыл бұрын
Hii sir..sir i m facing a problem... I am doing my final year project of BSIT ... My map is working but it doesn't show my device location and location symbol..please help me sir...i will be very grateful to you.
@abishekb185 жыл бұрын
Just turn on location in your device
@madhurahlawat30936 жыл бұрын
Cant resolve LocationService class Mitch. Help ASAP
@I3LACK-I3LOOD6 жыл бұрын
Same Problem, did you solve?
@cforge24116 жыл бұрын
I solved
@verdybangkityn18346 жыл бұрын
how?
@songsab26 жыл бұрын
How to solve?
@subhamgoyal52897 жыл бұрын
Sir ,can u make some video on family/friends tracking system
@josephjoey39047 жыл бұрын
Hey whatsapp, 😁 that would be nice
@subhamgoyal52897 жыл бұрын
Mitch Tabian yes sir.
@naniprasanna747 жыл бұрын
please show me how to add google and Facebook login to Instagram clone App.. share a video on integration process. thankx
@naniprasanna747 жыл бұрын
Actually I tried to integrate that stuff to this app, but its not working to me, I want to create an app by taking the reference of your app !!! that sounds good
@cforge24116 жыл бұрын
you still need it?
@wongzq6 жыл бұрын
For all those that have problems retrieving the device's current location (where it throws a NullPointerException) I added this line in the onCreate() function and it worked for me: mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this); You can refer to the Google Developers Guide for this. developer.android.com/training/location/retrieve-current.html#java
@7mzsZyns6 жыл бұрын
didn't work :/
@weachris74122 жыл бұрын
didnt work :(
@AmanGupta-ze7nt6 жыл бұрын
there is error in *mFusedLocationProviderClient* and i tried other ways but its not working. and the main cause is:- E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf; can anyone plz help.?
@svkrclg6 жыл бұрын
I am also getting the same problem
@AmanGupta-ze7nt6 жыл бұрын
Saurav Kumar well i got some solution. In gradle.build dependencies you have to write the same version of implementation.. e.g. if firebase auth have 12.0.1 then other google services must have the same version.
@svkrclg6 жыл бұрын
Yes bro, It worked. Thanks for the help
@yoavshahrabani45746 жыл бұрын
loc.addOnCompleteListener return task, which task.getResult return null what can I do please help me. And how did you got phone emulator with gps?
@codingwithmitch6 жыл бұрын
It's not an emulator. That's a real device. I'm using a Google chrome extension called "vysor" to mirror the screen on the computer.
@yoavshahrabani45746 жыл бұрын
CodingWithMitch And how can you check it on a real device? Did you just connect it via usb? Or did you do more than that? Do you have a video on it? Thank you!
@cforge24116 жыл бұрын
yes, with USB sometimes, there is some software needed too google has a age on it, try to find it if you can't , let me know
@samuelorji83967 жыл бұрын
hey mitch,i am getting an error using the FusedLocationProviderClient object to get the location,its returning a null value for me ...and i have been on stackoverflow all day seeking a solution, i haven't found anything...any help will be much appreciated
@samuelorji83967 жыл бұрын
Yes, i literally just copied your code from github into my project and its the same issue.. lemme attach a sample of the error message ****************************************************** Process: com.example.samuel.googlemaps, PID: 12847 java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference at com.example.samuel.googlemaps.MapActivity$1.onComplete(MapActivity.java:88) ********************************* I think another subscriber (Volkan Toprak) had the same issue
@samuelorji83967 жыл бұрын
I tried using mock locations and they worked....the camera map was able to zoom over to the places..my guess is that the problem is from here final Task location = mFusedLocationProviderClient.getLastLocation(); cos the location is actually returning null
@samuelorji83967 жыл бұрын
i have tried surrounding with a try/catch block, it caught the exception quite alright thus not making the camera to move to my location. I'll still keep on trying to debug it.Thanks so much for the response...really really means a lot
@samuelorji83967 жыл бұрын
hey mitch, i think was able to find a workaround, according to this post *************** stackoverflow.com/a/29854418 *************************** i just opened google maps first...then ran the app and it ran smoothly...finally i can continue with the course......... i'll still try to see if that can be avoided though
@samuelorji83967 жыл бұрын
Mitch Tabian just noticed that the GetLocation method only works when I have google maps actually running .....cos anytime I restart my phone and try ...it doesn't work... I saw something like fusedlocationclient.requireUpdates() ...as a method.....couldn't really understand it....maybe once I'm done with your course..I'll just create a new branch to use the method ....so I don't always have to use google maps ...Thanks.
@ubaidurrehman76686 жыл бұрын
my current location not shown .. please tell me the problem
@abdelrahmanazab95154 жыл бұрын
??
@kiranmarrapu6 жыл бұрын
A very nice article.
@niimisshagarg80646 жыл бұрын
hello sir.....sir i m facing a problem...my map is not being shown...it is displaying everything except for the map...please help sir...i will be very grateful...
@bilalyousaf69025 жыл бұрын
hii.. my map is working but it can't show device location,how you can solved it?
@aghaaful5 жыл бұрын
great work Sir!
@himanshunegi32165 жыл бұрын
hey bro I am getting null object reference on getMapAsync() what should I do Please Help. I am a newbie Thank You
@volkantoprak51327 жыл бұрын
Hello Mitch, first of all, thanks a lot for this awesome tutorial. I found an error. If user's last location is not known then null pointer exception occurs since currentLocation is null. This occurs if user did not turn on gps. I am still searching the best solution. I just wanted to inform you.
@samuelorji83967 жыл бұрын
having the same error
@samuelorji83967 жыл бұрын
try to run your default google maps and get your location first..then try the app again..mine worked after that .... i got it from this post stackoverflow.com/a/29854418
@subotai457 жыл бұрын
You can try to run the project in a physical android device instead of the emulator, that worked for me.
@ouahabhadilzineb29554 жыл бұрын
thank you so much god bless u
@gaoyunlong94036 жыл бұрын
Anyone faced this error?Im stuck now! E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.a42411.myapplication, PID: 2082 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
@amarcool75306 жыл бұрын
Sir can you please make a video in which you we can know the current longitude and latitude with country name please sir please
@Anime-Freak7146 жыл бұрын
activity_map is red(error) now can you please tell me how to solve this problem
@Anime-Freak7146 жыл бұрын
its fine i fixed that problem
@bilalyousaf69025 жыл бұрын
who got the solution of this video? I'm not getting device location help me out please...
@anasraza97095 жыл бұрын
If you are getting null pointer exception like "java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference" Cope this getDeviceLocation() method: public void getDeviceLocation(){ Log.d(TAG, "getDeviceLocation: getting the device current location"); fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this); try { if(mLocationPermissionGranted){ Task task = fusedLocationProviderClient.getLastLocation(); task.addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(Location location) { if(location != null){ Log.d(TAG, "onComplete: found location!"); moveCamera(new LatLng(location.getLatitude(),location.getLongitude()), DEFAULT_ZOOM); }else{ Log.d(TAG, "onComplete: current location is null"); Toast.makeText(GoogleMapsActivity.this,"Unable to get current location", Toast.LENGTH_LONG).show(); } } }); } }catch (SecurityException e){ Log.d(TAG, "getDeviceLocation: SecurityException: " + e.getMessage()); } }
@RShienh6 жыл бұрын
FusedLocationProviderClient is deprecated
@markdelrosario42316 жыл бұрын
how do you fix that problem sir?
@RShienh6 жыл бұрын
@@markdelrosario4231 I checked the documentation and found a way around. I don't remember it now.
@markdelrosario42316 жыл бұрын
i get it sir thank you! 😊
@nvlogs89166 жыл бұрын
Great tutorials! Please make tutorials on Google directions Api Please Please Please!!!!! They will be very useful..........