audio_service
audio_service copied to clipboard
Making custom activity the recommended option for Android implementation.
To which pages does your suggestion apply?
- https://github.com/ryanheise/audio_service/blob/minor/audio_service/README.md
Quote the sentences(s) from the documentation to be improved (if any)
If your app uses a custom activity, you will need to override provideFlutterEngine as follows to ensure that your activity and service use the same shared Flutter engine:
public class CustomActivity extends FlutterActivity {
@Override
public FlutterEngine provideFlutterEngine(Context context) {
return AudioServicePlugin.getFlutterEngine(context);
}
}
Describe your suggestion
I think a custom activity should be declared a recommended option for Android implementation, as it is less intrusive and more scalable (if you ever need to implement other custom code or use other plugin).
Also I think this code should be a new example as it explains clearly what needs to be done for the custom activity to work.
package com.yourcompany.yourappname;
import android.content.Context;
import com.ryanheise.audioservice.AudioServicePlugin;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
class MainActivity : FlutterActivity() {
override fun provideFlutterEngine(context: Context): FlutterEngine? {
return AudioServicePlugin.getFlutterEngine(context)
}
}
...
I think a custom activity should be declared a recommended option for Android implementation, as it is less intrusive and more scalable (if you ever need to implement other custom code or use other plugin).
For the average person who is building a Flutter app, they are unlikely to understand the finer details of what a custom activity would be useful for, and fortunately they don't need to know. Most Flutter apps do not need custom activities. And at the same time, anyone who actually does need a custom activity is probably doing something more sophisticated, and they are the type of person who should have no trouble reading the section on custom activities instead of just going with the default.
For the example, do you mean that the language should be changed to Kotlin and the import and package statements should be written explicitly in the documentation? I think that may be helpful, although probably both Kotlin and Java examples should be included.
For the average person who is building a Flutter app, they are unlikely to understand the finer details of what a custom activity would be useful for, and fortunately they don't need to know. Most Flutter apps do not need custom activities. And at the same time, anyone who actually does need a custom activity is probably doing something more sophisticated, and they are the type of person who should have no trouble reading the section on custom activities instead of just going with the default.
I think you are right, perhaps some of the drawbacks could be outlined in the documentation to notify the people who don't know much about how activities work?
For the example, do you mean that the language should be changed to Kotlin and the import and package statements should be written explicitly in the documentation? I think that may be helpful, although probably both Kotlin and Java examples should be included.
Yes, I think the imports should be included for clarification. As to the language either one is fine but as you mentioned including both is probably the best option.
very necessary
What exactly are you referring to? That this should be recommended as the default option? If so, I disagree, but if not I'm really not sure what your comment means.
Related issue, where i need to use .MainActivity
@renanmgs in your related issue you say that you need to change the main activity to .AudioServiceActivity
but that is not true. The README currently does give instructions on how to create a custom activity, notwithstanding the suggested doc improvements above.
If you are encountering a problem with the deep linking behaviour, you will need to open a separate bug report and provide a reproduction project so that I can investigate and fix the issue. But that is best organised as a separate issue.
If you are encountering a problem with the deep linking behaviour, you will need to open a separate bug report and provide a reproduction project so that I can investigate and fix the issue. But that is best organised as a separate issue.
Yes i am, and i will. Your activity does not permit deep linking in COLD state. Here it is.
Hello @ryanheise,
When I use
android:name="com.ryanheise.audioservice.AudioServiceActivity"
In my application activity xml, everything work except my payment stripe implementation with the package:https://pub.dev/packages/stripe_payment
I'm really confused what I have to do know to get both audio_service and stripe_payment
Can you help me ?
@yelkamel your comment is off topic to this issue, so I will mark it so. Please open a new bug report if there's a bug, or if you just have a question please seek help on StackOverflow.
I think that below part of the Android setup (https://pub.dev/packages/audio_service#android-setup) should come with a huge disclaimer, as below code:
<!-- EDIT THE android:name ATTRIBUTE IN YOUR EXISTING "ACTIVITY" ELEMENT -->
<activity android:name="com.ryanheise.audioservice.AudioServiceActivity" ...>
...
</activity>
really breaks things which rely on external plugins.
@NatanielRegula Thank you for the example, I was confused with how to extend the activity as I'm not an Android dev.