More intuitive way to configure audio_service on Android (AndroidManifest.xml)
Documentation link
https://pub.dev/packages/audio_service#android-setup
Your suggestion
I noticed there is an easier way to possibly set up this package on Android. It has to do with the step where an existing AndroidManifest.xml is modified. Specifically where <activity android:name=".MainActivity"> ... </activity> gets changed to <activity android:name="com.ryanheise.audioservice.AudioServiceActivity"> ... </activity> For me it was more convenient to extend from AudioServiceActivity and leave that line in the XML untouched like so:
public class MainActivity extends AudioServiceActivity {
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
// Aditionally set up any Platform channels
}
}
This could make it easier for existing projects that might be using platform channels or other platform specific code.
Possibly. One concern is that I remember reading in the past that Flutter's default app template was going to remove the MainActivity class altogether. I don't think they ended up doing that, but that sort of case would make the current approach the only reliable approach.