-
Notifications
You must be signed in to change notification settings - Fork 124
App automatically keeps coming in to the foreground after closing in few Devices #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's hard to understand the question. Could you please explain a little more in detail? |
Okk, when app opens , am starting Foreground services , without callbacks and StickyNotification:false , and After that am starting Bluetooth Scan , Now when user minimise the app by pressing Home Button,. bluetooth device scanning is still in progress in the App |
That's weird. This plugin does not have the ability to force the app to launch or open it. Is this a problem with this plugin? Can you try removing the |
am not using WithForegroundTask Widget , thats my code for starting Foreground task from splash screen Future<void> StratAndroidBackground() async {
await FlutterForegroundTask.init(
androidNotificationOptions: AndroidNotificationOptions(
channelId: 'notification_channel_id',
channelName: 'Foreground Notification',
channelDescription:
'This notification appears when the foreground service is running.',
channelImportance: NotificationChannelImportance.LOW,
priority: NotificationPriority.LOW,
isSticky: false,
iconData: const NotificationIconData(
resType: ResourceType.mipmap,
resPrefix: ResourcePrefix.ic,
name: 'launcher',
),
buttons: [
// const NotificationButton(id: 'sendButton', text: 'Send'),
// const NotificationButton(id: 'testButton', text: 'Test'),
],
),
iosNotificationOptions: const IOSNotificationOptions(
showNotification: true,
playSound: false,
),
foregroundTaskOptions: const ForegroundTaskOptions(
interval: 5000,
autoRunOnBoot: false,
allowWifiLock: false,
),
printDevLog: true,
);
///Check If Background Service is already running
bool isIgnoringBatteryOptimisations =
await FlutterForegroundTask.isIgnoringBatteryOptimizations;
if (!isIgnoringBatteryOptimisations) {
await FlutterForegroundTask.requestIgnoreBatteryOptimization();
}
bool isRunning = await FlutterForegroundTask.isRunningService;
if (isRunning) return;
await FlutterForegroundTask.startService(
notificationTitle: "Service is running in background",
notificationText: "Tap to open",
// callback: startCallback,
);
} can it be something related to Samsung device , because am not facing such issue in my Device on Stock android |
I'm new to this too, so I don't know why it's causing the problem. One guess is that searching for Bluetooth is the cause. Would you like to test by turning off the Bluetooth scan function for a while? |
There doesn't seem to be any problems with setting up and starting the foreground service. |
Okk Thanks , will try to check what exactly causing this issue |
@Dev-hwang ,finally fixed it , actually in few device ,while scanning , i was checking if bluetooth is on or not , and when that native call happens for checking , app auto came to foreground in few devices , altough am not sure why this was happening but modifying that bluetooth check code fix the problem |
Hey , in Few Devices ,App opens automatically
tested in Samsung S8+ ,Android version is 9 ,
auto_foreground.mp4
attached a video of issue , i can't really figure out why this is happening ,
Altough its working fine on my device , One plus 8T ,android V11
The text was updated successfully, but these errors were encountered: