Skip to content

Instantly share code, notes, and snippets.

View DanishAmjad12's full-sized avatar
🎯
Focusing

Danish DanishAmjad12

🎯
Focusing
View GitHub Profile
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Text("Hello Text")
}
}
}
private fun checkUpdate() {
// Returns an intent object that you use to check for an update.
val appUpdateInfoTask = appUpdateManager?.appUpdateInfo
// Checks that the platform will allow the specified type of update.
Log.d(TAG, "Checking for updates")
appUpdateInfoTask?.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
// Request the update.
Log.d(TAG, "Update available")
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
AppUpdateType.FLEXIBLE,
// The current activity making the update request.
this,
// Include a request code to later monitor this update request.
MY_REQUEST_CODE)
private val listener: InstallStateUpdatedListener? = InstallStateUpdatedListener { installState ->
if (installState.installStatus() == InstallStatus.DOWNLOADED) {
// After the update is downloaded, show a notification
// and request user confirmation to restart the app.
Log.d(TAG, "An update has been downloaded")
showSnackBarForCompleteUpdate()
}
}
dependencies {
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
}
dependencies {
implementation 'com.google.mlkit:entity-extraction:16.0.0-beta2'
}
val entityExtractor =
EntityExtraction.getClient(
EntityExtractorOptions.Builder(EntityExtractorOptions.ENGLISH)
.build())
entityExtractor
.downloadModelIfNeeded()
.addOnSuccessListener { _ ->
/* Model downloading succeeded, you can call extraction API here. */
}
.addOnFailureListener { _ -> /* Model downloading failed. */ }
entityExtractor
.downloadModelIfNeeded()
.addOnSuccessListener { _ ->
//step3
val params =
EntityExtractionParams.Builder("My flight is LX373")
.build()
entityExtractor
.annotate(params)
.addOnSuccessListener {
class Drawing @JvmOverloads constructor(
context: Context?,
attributeSet: AttributeSet? = null
) :
View(context, attributeSet) {
private val currentStrokePaint: Paint = Paint()
private val canvasPaint: Paint
private val currentStroke: Path
private lateinit var drawCanvas: Canvas
private lateinit var canvasBitmap: Bitmap