File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
app/src/main/java/com/github/droidworksstudio/common Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -304,22 +304,16 @@ fun Context.launchClock() {
304304
305305fun Context.launchCalendar () {
306306 try {
307- val cal: Calendar = Calendar .getInstance()
308- cal.time = Date ()
309- val time = cal.time.time
310- val builder: Uri .Builder = CalendarContract .CONTENT_URI .buildUpon()
311- builder.appendPath(" time" )
312- builder.appendPath(time.toString())
313- this .startActivity(Intent (Intent .ACTION_VIEW , builder.build()))
314- } catch (_: Exception ) {
315- try {
316- val intent = Intent (this , LauncherActivity ::class .java)
317- intent.addCategory(Intent .CATEGORY_APP_CALENDAR )
318- this .startActivity(intent)
307+ // Fallback: Open the Calendar app using category
308+ val fallbackIntent = Intent (Intent .ACTION_MAIN ).apply {
309+ addCategory(Intent .CATEGORY_APP_CALENDAR )
310+ flags = Intent .FLAG_ACTIVITY_NEW_TASK
311+ }
312+ this .startActivity(fallbackIntent)
319313 } catch (e: Exception ) {
320- Log .e(" openCalendar" , e.toString())
314+ // Log any error if both methods fail
315+ Log .e(" openCalendar" , " Failed to open Calendar: ${e.message} " )
321316 }
322- }
323317}
324318
325319fun Context.openBatteryManager () {
You can’t perform that action at this time.
0 commit comments