Skip to content

Instantly share code, notes, and snippets.

View ForceGT's full-sized avatar
🎯
Focusing

Gaurav Thakkar ForceGT

🎯
Focusing
View GitHub Profile
@ForceGT
ForceGT / gist:4d4faa3318b22dac5638c7ba467795a3
Last active December 7, 2023 06:03
Screenshot detection observer for Android 14+, without tying the logic to a specific activity
object ScreenshotUtils {
private lateinit var screenCaptureCallback: Activity.ScreenCaptureCallback
fun Activity.observeScreenShotDetection(onScreenShotDetected: () -> Unit) {
// TODO Add API Check here
(this as LifecycleOwner).lifecycle.addObserver(
object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
screenCaptureCallback = Activity.ScreenCaptureCallback(onScreenShotDetected)
@ForceGT
ForceGT / AdMob Interstitial Ad SwiftUI
Created February 9, 2021 14:29
Code snippet showing how to use AdMob with SwiftUI (updated for Jan 2021)
// First create a dedicated class for this
```
import SwiftUI
import GoogleMobileAds
class Interstitial : NSObject,GADFullScreenContentDelegate{
var interstitial : GADInterstitialAd = GADInterstitialAd.init()
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
@ForceGT
ForceGT / receiptbuilder.dart
Created October 11, 2020 16:36
Error in dart pdf generation
import 'dart:typed_data';
import 'models/reciept.dart';
import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'models/user.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
import 'dart:io';
class ReceiptBuilder {
// All files to be placed inside MainActivity.java file
package com.example.examplehelloworld;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ForceGT
ForceGT / Demo
Last active July 21, 2020 12:37
package com.myappcompany.rob.currencyconverter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
package com.gtxtreme.punecoronatracker
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.anychart.AnyChart
import com.anychart.chart.common.dataentry.DataEntry
@ForceGT
ForceGT / C
Created May 2, 2020 08:36
C Basics
Basic Topics To Be Covered:
Preprocessor Directives
Functions,Variables,Tokens,Semicolons,Comments,Identifiers
Basic Data Types in C:
Basic: int,float,long,double,char,void
Enumerations
@ForceGT
ForceGT / MySVG.svg
Created April 23, 2019 18:53
Random SVG code just for copy paste sake
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ForceGT
ForceGT / MainActivity.java
Created March 26, 2019 15:52
Random Java Code
package com.gtxtreme.firebaseauthentication;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;