Skip to content

Instantly share code, notes, and snippets.

View muhammad-hamza-shahid's full-sized avatar
💻
Learning

Muhammad Hamza Shahid muhammad-hamza-shahid

💻
Learning
View GitHub Profile
@muhammad-hamza-shahid
muhammad-hamza-shahid / InternetManager.kt
Created June 30, 2022 09:44
Internet Manger to check connection status
object InternetManager {
fun checkForInternet(context: Context): Boolean {
// register activity with the connectivity manager service
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
// if the android version is equal to M
// or greater we need to use the
// NetworkCapabilities to check what type of
// network has the internet connection
@muhammad-hamza-shahid
muhammad-hamza-shahid / FragmentExtension.kt
Last active November 29, 2022 07:50
Safe navigation using Navigation Component Jetpack Android (DeepLink, Action, Fragment Name)
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.annotation.IdRes
import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.DialogFragmentNavigator
import androidx.navigation.fragment.FragmentNavigator
import androidx.navigation.fragment.findNavController