File tree Expand file tree Collapse file tree 4 files changed +34
-30
lines changed
app/src/main/java/com/pureswift/swiftandroid
swift/Sources/SwiftAndroidApp Expand file tree Collapse file tree 4 files changed +34
-30
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package com.pureswift.swiftandroid
2+
3+ import com.example.swift.HelloSubclass
4+
5+ class Application : android.app.Application () {
6+
7+ init {
8+ NativeLibrary .shared()
9+ }
10+
11+ override fun onCreate () {
12+ super .onCreate()
13+ onCreateSwift()
14+ }
15+
16+ private external fun onCreateSwift ()
17+
18+ override fun onTerminate () {
19+ super .onTerminate()
20+ onTerminateSwift()
21+ }
22+
23+ private external fun onTerminateSwift ()
24+
25+ fun sayHello () {
26+ val result = HelloSubclass (" Swift" ).sayHello(17 , 25 )
27+ println (" sayHello(17, 25) = $result " )
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ class NativeLibrary private constructor() {
2727 System .loadLibrary(" SwiftAndroidApp" )
2828 } catch (error: UnsatisfiedLinkError ) {
2929 Log .e(" NativeLibrary" , " Unable to load native libraries: $error " )
30+ return
3031 }
32+ Log .d(" NativeLibrary" , " Loaded Swift library" )
3133 }
3234}
Original file line number Diff line number Diff line change 88import AndroidKit
99
1010@JavaClass ( " com.pureswift.swiftandroid.Application " )
11- public class Application : JavaObject {
11+ public class Application : AndroidApp . Application {
1212
1313 @JavaMethod
1414 public func sayHello( )
@@ -18,17 +18,15 @@ public class Application: JavaObject {
1818public extension Application {
1919
2020 @JavaMethod
21- public func onCreate( ) {
22- //super.onCreate()
21+ public func onCreateSwift( ) {
2322
2423 print ( " \( #function) " )
2524
2625 sayHello ( )
2726 }
2827
2928 @JavaMethod
30- public func onTerminate( ) {
31- //super.onTerminate()
29+ public func onTerminateSwift( ) {
3230
3331 print ( " \( #function) " )
3432 }
You can’t perform that action at this time.
0 commit comments