Skip to content

Instantly share code, notes, and snippets.

@amit-cod
amit-cod / install google play services in android studio
Created May 8, 2016 05:53
install google play services in android studio
Add the correct dependencies into the build.gradle file:
All those answers are wrong, since the release of gradle plugin v0.4.2 the setup of google play services under android studio is straight forward. You don't need to import any jar or add any project library nor add any new module under android studio. What you have to do is to add the correct dependencies into the build.gradle file. Please take a look to those links: Gradle plugin v0.4.2 update, New Build System, and this sample
The Correct way to do so is as follows:
First of all you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.
Restart android studio and open the build gradle file. You must modify your build.gradle file to look like this under dependencies:
```
@amit-cod
amit-cod / mapbox-get-current-latlong-android.java
Created April 19, 2016 06:59
How to get latitude, longitude and altitude of user's current location using mapbox
MapView mv;
private UserLocationOverlay myLocationOverlay= myLocationOverlay = new UserLocationOverlay(new GpsLocationProvider(this), mv);
myLocationOverlay.setDrawAccuracyEnabled(true);
myLocationOverlay.enableMyLocation();
LatLng latlong =myLocationOverlay.getMyLocation();
Double myLatitide= latlong.getLatitude();
Double mylongitude = latlong.getLongitude();
Double myAltitude = latlong.getAltitude();
@amit-cod
amit-cod / Custom-marker-mapbox-Android.java
Created April 19, 2016 06:58
How to add custom image as a marker in MapBox
Marker m;
MapView mv;
Drawable myIcon = getResources().getDrawable( R.drawable.ic_launcher );
m = new Marker(mv, "hi", "hello", new LatLng(77.0875, 14.42112));
m.setMarker(myIcon);
m.setTitle("Hello Android");
m.setDescription("This is Technicise");
mv.addMarker(m);