Stripe Payment Conflicting -> MainActivity.kt extends with FlutterFragmentActivity

56 Views Asked by At

This is my native Android class MainActivity.kt

class MainActivity : FlutterFragmentActivity(), AudioServiceActivity(){}

Error The AudioServiceActivity was extended already when I started implementing Stripe I also have to implement FlutterFragmentActivity with MainActivity But it causes errors.
How do I implement both activities with MainActivity?

#Flutter #flutter_stripe

enter image description here

I tried composition and made interface for both

I tried to implement only one Activity at a time and make Object of second Activity to utilize but causing issue still

1

There are 1 best solutions below

0
Samee Hassan On

I resolved this issue by, I made an Interface for one class AudioServiceActivity(), and overridden its functions in the interface. Then implement my interface on Mainactivity.kt And implement the override function in Mainactivity.kt like this,

class MainActivity : FlutterFragmentActivity(),AudioServiceInterface{
override fun provideFlutterEngine(context: android.content.Context): FlutterEngine? {
    return AudioServicePlugin.getFlutterEngine(context)
  }
}

and this is my interface

interface AudioServiceInterface { fun provideFlutterEngine(context: Context): FlutterEngine? }