Fix: Testing a fix for calendar apps
This commit is contained in:
@@ -304,22 +304,16 @@ 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(fallbackIntent)
|
||||||
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) {
|
} catch (e: Exception) {
|
||||||
Log.e("openCalendar", e.toString())
|
// Log any error if both methods fail
|
||||||
|
Log.e("openCalendar", "Failed to open Calendar: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.openBatteryManager() {
|
fun Context.openBatteryManager() {
|
||||||
|
|||||||
Reference in New Issue
Block a user