Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created November 6, 2022 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arunshaik2001/f20e73d5303fffc8eec81b3cce70cd53 to your computer and use it in GitHub Desktop.
Save Arunshaik2001/f20e73d5303fffc8eec81b3cce70cd53 to your computer and use it in GitHub Desktop.
val data: Uri? = intent.data
if (Intent.ACTION_SEND == intent.action) {
val isSchemaSame = data?.scheme == this.getString(R.string.app_name_lowercase)
val isHostSame = data?.host == "reminder"
if (isSchemaSame && isHostSame) {
val title = data?.getQueryParameter("title")
val description = data?.getQueryParameter("description")
val startTimeInMillis = data?.getQueryParameter("startTimeInMillis")
val reminderType = data?.getQueryParameter("reminderType")
val startTimeInInstant = startTimeInMillis?.toLong()
?.let { Instant.ofEpochMilli(it) }
showSetReminderScreen.postValue(true)
reminderData.postValue(
Reminder(
id = -1,
title = title ?: "",
description = description ?: "",
reminderStart = startTimeInInstant ?: Instant.now(),
remindType = RemindType.valueOf(reminderType ?: ""),
reminderEnd = Instant.now()
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment