In my Flutter application, I want to implement Recents URL sharing via plugin.
This feature can be implemented by overriding the onProvideAssistContent
method in the Activity
class.
From what I know, we can obtain the main activity instance by implementing the ActivityAware interface's methods in the plugin class.
But I don't know how to override the onProvideAssistContent
method via the obtained Activity instance.
I tried asking ChatGPT to get the answer. I asked it if I wanted to override the onCreate
method (instead of onProvideAssistContent
, because onCreate
is more general). ChatGPT replied that I need to specify the main Activity class pointing to a class defined in the plugin. In this way, the main activity belongs to the plugin, which I am not happy to do. And I continued by asking what happens if 2 plugins doing like this, and it answered: (Due to Temporary policy: ChatGPT is banned, I strikethroughed the text generated by ChatGPT).If two plugins both define their own onCreate() method for the same activity, only one of them will be called. The behavior in this case is determined by the order in which the plugins are loaded.
My questions are
- How can I implement the Recents URL sharing in Flutter via a plugin?
- How to override Android Activity class methods such as onCreate/onProvideAssistContent in flutter plugin?