Skip to content

Instantly share code, notes, and snippets.

• FusedLocationProviderClient - get location update continuously.
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
• MainActivity
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
@willu2
willu2 / MainActivity.java
Created May 12, 2020 20:37 — forked from Aeonitis/MainActivity.java
Android - Check Network State in your app, Notifying you when an app is online/offline
/**
* This would be the activity which registers the receiver class via it's interface
*/
public class MainActivity implements NetworkStateReceiver.NetworkStateReceiverListener {
private NetworkStateReceiver networkStateReceiver; // Receiver that detects network state changes
@Override
protected void onCreate(Bundle savedInstanceState) {
/***/
@willu2
willu2 / drawSector
Created April 18, 2020 20:52 — forked from Lmendev/drawSector.js
Function to create a semicircle with Google Maps API v3. Coordinated and azimuth data are required. This is an adaptation of https://groups.google.com/forum/#!topic/google-maps-api/rKefiTZPXE8
function drawSector(lat, lng, r, azimuth, width) {
var centerPoint = new google.maps.LatLng(lat, lng);
var PRlat = (r/3963) * (180 / Math.PI); // using 3963 miles as earth's radius
var PRlng = PRlat/Math.cos(lat*((Math.PI / 180)));
var PGpoints = [];
PGpoints.push(centerPoint);
with (Math) {
lat1 = lat + (PRlat * cos( ((Math.PI / 180)) * (azimuth - width/2 )));
lon1 = lng + (PRlng * sin( ((Math.PI / 180)) * (azimuth - width/2 )));
@willu2
willu2 / AA Transition App theme between light and dark themes
Created February 13, 2016 15:39 — forked from alphamu/AA Transition App theme between light and dark themes
Example of how to change themes at runtime with a smooth animation. In this example, we just switch between a light and a dark theme. The activity animation is defined in the theme and as such will be default on all activities with the set theme. [Demo Video here](http://youtu.be/Ps0phswbHls).
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
public class TransitionThemeActivity extends AppCompatActivity implements View.OnClickListener {
@willu2
willu2 / Color theme - NavigationDrawer-Material Design
Created February 12, 2016 09:59 — forked from zirouan/Color theme - NavigationDrawer-Material Design
Color theme - NavigationDrawer-Material Design
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="nliveo_white">#ffffff</color>
<color name="nliveo_grey">#e0e0e0</color>
<color name="nliveo_black">#000000</color>
<color name="nliveo_transparent">#00000000</color>
<color name="nliveo_blue_colorPrimary">#2196F3</color>
<color name="nliveo_blue_colorPrimaryDark">#1976D2</color>
<color name="nliveo_blue_alpha_colorPrimaryDark">#801976D2</color>