I am trying to configure local_auth in my flutter app and I came across following instructions local_auth plugin Android Integration.
local_auth plugin requires the use of a FragmentActivity instead of Activity. This can be easily done by switching FlutterFragmentActivity to FlutterActivity in the manifest (or your own Activity class if you are extending the base class).
Following is my MainActivity class code snippets:
package com.example.xxxxxxxx;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import com.anggach.flutterandroidlifecycle.FlutterAndroidLifecycleActivity;
import io.flutter.app.FlutterFragmentActivity;
public class MainActivity extends FlutterAndroidLifecycleActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
But my problem is that MainActivity class in my code is already extending from FlutterAndroidLifecycleActivity, and I am not able to extend it from two packages.
Some additional details: I tried to resolve it by putting both the classes together but didn't get success because Java doesn't support Multiple Inheritance.
There are other resources about this in Java as:
Extending from two classes
Can one class extend two classes?
To summarise the issue, I need to be able to extend both FlutterFragmentActivity and FlutterAndroidLifecycleActivity from MainActivity
In MainActivity.java:
package com.your.package;
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterFragmentActivity {
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With