FlutterActivity vs FlutterFragmentActivity
Asked Answered
A

2

9

I was trying to implement local_auth package into my Flutter app.

in the documentation, it was mentioned that it will have to use FlutterFragmentActivity instead of FlutterActivity in my MainActivity class.

So I wanted to know what are the main differences between FlutterFragmentActivity and FlutterActivity and how both impact app's performance?

:) as I don't want to make a change and break the app in production.

Alba answered 2/2, 2022 at 7:48 Comment(1)
FlutterFragmentActivity exists because there are some Android APIs in the ecosystem that only accept a FragmentActivity. If a FragmentActivity is not required, you should consider using a regular FlutterActivity instead, because FlutterActivity is considered to be the standard, canonical implementation of a Flutter Activity.Wideawake
C
6

A FragmentActivity is a subclass of Activity that was built for the Android Support Package.

The FragmentActivity class adds a couple of new methods to ensure compatibility with older versions of Android, but other than that, there really isn't much of a difference between the two.

https://developer.android.com/topic/libraries/support-library

Info from this thread https://mcmap.net/q/115968/-difference-between-activity-and-fragmentactivity

So, it doesn't impact performance.

Claudineclaudio answered 27/9, 2022 at 11:41 Comment(0)
F
0

In my apps, I see those activities act differently when you press back button (or perform back gesture) at the root screen of your app:

FlutterActivity: Your app will be closed.

FlutterFragmentActivity : Your app will be move to background.

Feathering answered 6/3, 2024 at 1:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.