Updated on 2026-08-14
This commit is contained in:
parent
922610a9ed
commit
3b04da7388
6 changed files with 86 additions and 54 deletions
|
|
@ -1,7 +1,11 @@
|
|||
package com.tangem.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkInfo
|
||||
import com.google.zxing.BarcodeFormat
|
||||
import com.google.zxing.EncodeHintType
|
||||
import com.google.zxing.WriterException
|
||||
|
|
@ -32,4 +36,16 @@ object UtilHelper {
|
|||
return bmp
|
||||
}
|
||||
|
||||
fun isOnline(context: Activity): Boolean {
|
||||
return try {
|
||||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val netInfo: NetworkInfo?
|
||||
netInfo = cm.activeNetworkInfo
|
||||
netInfo != null && netInfo.isConnectedOrConnecting
|
||||
} catch (e: NullPointerException) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue