From 2e36aa5b775b15185eaac9f211d3beda15bc0aa9 Mon Sep 17 00:00:00 2001 From: PranshulGG Date: Thu, 22 Jan 2026 17:19:18 +0530 Subject: [PATCH] fix: add methods to start and stop persistent notification service --- .../weather_master_app/MainActivity.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/app/src/main/kotlin/com/pranshulgg/weather_master_app/MainActivity.kt b/android/app/src/main/kotlin/com/pranshulgg/weather_master_app/MainActivity.kt index 8837ae864..48a459076 100644 --- a/android/app/src/main/kotlin/com/pranshulgg/weather_master_app/MainActivity.kt +++ b/android/app/src/main/kotlin/com/pranshulgg/weather_master_app/MainActivity.kt @@ -1,6 +1,7 @@ package com.pranshulgg.weather_master_app import android.content.Context +import android.content.Intent import android.content.pm.PackageManager import android.os.Build import android.util.Log @@ -105,7 +106,22 @@ class MainActivity : FlutterActivity() { } "isOnline" -> { result.success(isOnline(this)) + } + "startPersistentNotification" -> { + val intent = Intent(this, WeatherPersistentNotificationService::class.java) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(intent) + } else { + startService(intent) } + result.success(true) + } + + "stopPersistentNotification" -> { + stopService(Intent(this, WeatherPersistentNotificationService::class.java)) + result.success(true) + } + else -> result.notImplemented() } }