Skip to content

Instantly share code, notes, and snippets.

View SurajBahadur's full-sized avatar
🎯
Focusing

Suraj Bahadur SurajBahadur

🎯
Focusing
View GitHub Profile
@SurajBahadur
SurajBahadur / AppOpenManager.kt
Created January 10, 2021 07:38
Sample Demo To Show App Open Ads
package com.example.myapplication.utils
import android.app.Activity
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import androidx.lifecycle.ProcessLifecycleOwner
@SurajBahadur
SurajBahadur / Register1Fragment.kt
Created August 16, 2020 12:03
Sample Code For Integrating Facebook In Android(Kotlin)
package com.app.base.ui.register.view
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.app.base.R
@SurajBahadur
SurajBahadur / AdbCommands
Created August 4, 2020 21:38 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@SurajBahadur
SurajBahadur / Model.kt
Created January 18, 2020 07:14
Filter the model class based on like,comment and whatever you want in kotlin java
/**
Use below method to filter the list
Collections.sort(data.videos, MoreViewComparator())
*/
data class VideosItem(
@field:SerializedName("author_name")
val authorName: String? = null,
@field:SerializedName("updated_on")
@SurajBahadur
SurajBahadur / ScheduleVersesOfDay.kt
Created January 14, 2020 13:07
Showing display after 15 minutes using work manager
class ScheduleVersesOfDay(private var context: Context,private var workerParams: WorkerParameters) : Worker(context, workerParams) {
override fun doWork(): Result {
Log.e(TAB, "PeriodicWork in BackGround")
sendNotification("Work Manager", "This is the scheduled notification")
return Result.success()
}
companion object {
private val TAB = ScheduleVersesOfDay::class.java.simpleName
}
@SurajBahadur
SurajBahadur / LocationService.kt
Last active July 4, 2020 17:35
Global to get the user current location and ask permission to enable location on his device
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.location.Location
import android.net.Uri
import android.os.Looper
import android.provider.Settings
@SurajBahadur
SurajBahadur / MainActivity.kt
Created December 26, 2019 12:33
Image Compressing In Kotlin
package com.e.imagecompressor
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.database.Cursor
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Bundle
@SurajBahadur
SurajBahadur / PhonecallReceiver.java
Created December 18, 2019 11:59 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@SurajBahadur
SurajBahadur / bg_corner_white.xml
Created December 13, 2019 13:25
For around me
<?xml version="1.0" encoding="utf-8"?><!-- res/drawable/rounded_edittext_focused.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#33363E" />
<stroke
android:width="0.9dp"
@SurajBahadur
SurajBahadur / multilinecolor.xml
Created November 28, 2019 13:05
Line with multi colors
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#ff0000"/>
</shape>
</item>
<item
android:right="50dp">
<shape>