Skip to content

Commit da7e1e7

Browse files
committed
Fixed MainActivity.onCreate()
1 parent a717424 commit da7e1e7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Demo/app/src/main/swift/MainActivity.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension MainActivity {
3535
public func onCreateSwift(_ savedInstanceState: BaseBundle?) {
3636
log("\(self).\(#function)")
3737

38-
_onCreate()
38+
_onCreate(savedInstanceState)
3939
}
4040
}
4141

@@ -45,10 +45,16 @@ private extension MainActivity {
4545
typealias MainActor = AndroidMainActor
4646
#endif
4747

48-
func _onCreate() {
49-
MainActivity.shared = self
50-
runAsync()
51-
startMainRunLoop()
48+
func _onCreate(_ savedInstanceState: BaseBundle?) {
49+
50+
// setup singletons
51+
if savedInstanceState == nil, MainActivity.shared == nil {
52+
MainActivity.shared = self
53+
startMainRunLoop()
54+
runAsync()
55+
}
56+
57+
// need to recreate views
5258
setRootView()
5359
}
5460

@@ -130,7 +136,6 @@ private extension MainActivity {
130136
_ = getFragmentManager()
131137
.beginTransaction()
132138
.replace(rootViewID, homeFragment)
133-
.addToBackStack(nil)
134139
.commit()
135140

136141
// Set as the content view

0 commit comments

Comments
 (0)