Fix: Testing a fix for calendar apps

This commit is contained in:
HᴇCᴏᴅᴇs2ᴍᴜᴄʜ
2024-12-05 07:45:25 +00:00
committed by GitHub
parent 91cea2fd9e
commit d7a62aa4c1

View File

@@ -304,21 +304,15 @@ fun Context.launchClock() {
fun Context.launchCalendar() { fun Context.launchCalendar() {
try { try {
val cal: Calendar = Calendar.getInstance() // Fallback: Open the Calendar app using category
cal.time = Date() val fallbackIntent = Intent(Intent.ACTION_MAIN).apply {
val time = cal.time.time addCategory(Intent.CATEGORY_APP_CALENDAR)
val builder: Uri.Builder = CalendarContract.CONTENT_URI.buildUpon() flags = Intent.FLAG_ACTIVITY_NEW_TASK
builder.appendPath("time")
builder.appendPath(time.toString())
this.startActivity(Intent(Intent.ACTION_VIEW, builder.build()))
} catch (_: Exception) {
try {
val intent = Intent(this, LauncherActivity::class.java)
intent.addCategory(Intent.CATEGORY_APP_CALENDAR)
this.startActivity(intent)
} catch (e: Exception) {
Log.e("openCalendar", e.toString())
} }
this.startActivity(fallbackIntent)
} catch (e: Exception) {
// Log any error if both methods fail
Log.e("openCalendar", "Failed to open Calendar: ${e.message}")
} }
} }