Skip to content

Instantly share code, notes, and snippets.

View harilee1325's full-sized avatar

Harilee harilee1325

View GitHub Profile
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def album():
return render_template("album.html")
public class App extends Application {
public static final String CHANNEL_ID = "channel 1";
@Override
public void onCreate() {
super.onCreate();
createNotificationChannel();
}
private void createNotificationChannel() {
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
public class LocationService extends Service {
@Override
public IBinder onBind(Intent intent) {
return binder;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Intent notificationIntent = new Intent(this, MapsActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
public class MyBroadCastReceiver extends BroadcastReceiver {
private String audioFile;
@Override
public void onReceive(Context context, Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
String errorMessage = GeofenceStatusCodes.getStatusCodeString(geofencingEvent.getErrorCode());
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(geofenceList);
return builder.build();
}
private PendingIntent getGeofencePendingIntent() {
// Reuse the PendingIntent if we already have it.
if (geofencePendingIntent != null) {
private void addGeofence() {
geofencingClient.addGeofences(getGeofencingRequest(), getGeofencePendingIntent())
.addOnSuccessListener(this, aVoid -> {
Toast.makeText(getApplicationContext()
, "Geofencing has started", Toast.LENGTH_SHORT).show();
})
.addOnFailureListener(this, e -> {
Toast.makeText(getApplicationContext()
, "Geofencing failed", Toast.LENGTH_SHORT).show();
private List<Geofence> geofenceList = new ArrayList<>();
private PendingIntent geofencePendingIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
geofenceList.add(new Geofence.Builder()
// Set the request ID of the geofence. This is a string to identify this
dependencies {
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:4.3.3'