apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Whether there can be only one CordovaActivity in a project #1673

Closed EmptyPages closed 6 months ago

EmptyPages commented 6 months ago

What should I do if I need multiple activities

breautek commented 6 months ago

Each activity would have its own webview and plugin instances, so it doesn't really make a whole lot of sense to have more than one cordova activity unless if you're trying to run multiple cordova environments in a single application. I don't think anything prevents you from making more than one cordova activity at least at the framework level, but if any plugin stores static state, then there might be problems.

This is something not supported by the Cordova CLI, it would require you to manage a cordova project manually, which can be a daunting task and error-prone. It's also not a path that is tested and even if it works today, it may break without notice so I wouldn't really recommend creating more than one cordova activity.

What's your use case for using more than one cordova activity?

EmptyPages commented 6 months ago

it has no any use case ,i just wanna try it, thanks for your answer

jcesarmobile commented 6 months ago

Regular Cordova apps can only have one activity as breautek said. You can create a native android project and embed multiple cordova activities as documented here https://cordova.apache.org/docs/en/11.x/guide/platforms/android/webview.html But note that the documentation is very out of date as it has not been updated for several years and was not ever complete when it was published, still doable, but you are going to need to do the investigation on your own.

EmptyPages commented 6 months ago

Regular Cordova apps can only have one activity as breautek said. You can create a native android project and embed multiple cordova activities as documented here https://cordova.apache.org/docs/en/11.x/guide/platforms/android/webview.html But note that the documentation is very out of date as it has not been updated for several years and was not ever complete when it was published, still doable, but you are going to need to do the investigation on your own.

thanks,because i am no any use case , so i need not to try it. i just wanna to know this project better