-
Notifications
You must be signed in to change notification settings - Fork 231
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
Headless Setup #69
Comments
Next the instructions says to add this to my manifest, but mine already has
Should i replace the name .App with .Application instead? |
Have you managed to launch the plugin yet? |
i launched it in your example project, now im trying to integrate it into our project |
I suggest you keep it simple in the beginning. Implementing the Headless task with enableHeadless: true is an advanced topic best left for when you’re more experienced with the plugin. |
ok, where do i disable enableHeadless:true |
What do the docs tell you about Config.enableHeadless? |
i see it now, nice! |
And for the AndroidManifest.xml, for the headless configuration, If I create a custom <application
tools:replace="android:label"
android:name=".Banana" |
Thanks for your help, i never heard of headless mode before, i have so many questions about it. I have to research it more i guess.... Your description says headless is only an android thing (IOS dont have it). In android, when the app is terminated and you have headless enabled and there is an event, the registered headless function will be called. In IOS the whole app will wake up to process the event, while in android only that headless function that i register will exist. So im wondering.... when this registered headless function is called to process the event, will the rest of the app data exist and can be access by the headless function? For example will the data for the user that was logged in when the app went to sleep (or terminated by the OS) exist when the headless function is called, or is the headless function just hangout there is space by itself? What if i dont use the android headless feature, will the whole android app wake up (like the IOS app) to process the event instead? I guess i have to read up more on this headless thing..... Thanks anyway! |
In Headless context, your Flutter app, booted in
// Headless task
void backgroundGeolocationHeadlessTask() async {
print('[BackgroundGeolocation] headless task');
}
void main() { // <-- in Headless context, main() does NOT run.
runApp(new MyApp()); // <-- Your app does not launch in the headless context.
// Register to receive BackgroundGeolocation events after app is terminated.
// Requires {stopOnTerminate: false, enableHeadless: true}
bg.BackgroundGeolocation.registerHeadlessTask(backgroundGeolocationHeadlessTask);
} |
Thanks, but what if i dont use the headless feature, will the whole android app wake up instead of just the registered headless function? |
BackgroundGeolocation runs an android foreground-service. It remains running in spite of app termination (assuming you've configured Assuming by "whole app" you mean your UI you've declared in your Flutter app, no. That will never be launched automatically after the user or OS terminates your Android app. Someone might implement a headless-task to respond to geofence events for example. Maybe they want to display a notification if the device is near some shop offering a deal. Their headless-task would respond to geofence events and interact with some 3rd-party notification library. You don't need to implement a headless-task if you have nothing to do in the terminated context. The plugin is going to be tracking the location no matter what. |
Ok, sounds perfect. So i dont need headless. When the user terminates the app, everything is dead if StopOnTerminate:true (which is what we want). When the user terminates the app, we want everything to stop, no background tasks or event processing. But if the user switches to another app without terminating our app, or if our app goes to background mode because the screen went off, everything will still work once the user didnt manually terminate the app. |
|
Your setup instructions in github says.....
Headless Mechanism with enableHeadless: true
Create either Application.kt or Application.java in the same directory as MainActivity
I prefer using Application.java , but I dont see MainActivity anywhere in my flutter project tree, i just see a file called GeneratedPluginRegistrant.java should i place Application.java in that same folder?
Your Environment
flutter doctor
):PASTE_YOUR_CODE_HERE
Expected Behavior
Actual Behavior
Steps to Reproduce
Context
Debug logs
Logs
The text was updated successfully, but these errors were encountered: