feat: add basic rust JNI demo
This commit is contained in:
parent
954d100742
commit
8d1472b5a7
6 changed files with 61 additions and 0 deletions
8
app/src/main/java/net/mbess/popequer/Native.kt
Normal file
8
app/src/main/java/net/mbess/popequer/Native.kt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package net.mbess.popequer
|
||||
|
||||
object Native {
|
||||
init {
|
||||
System.loadLibrary("rustsandbox")
|
||||
}
|
||||
external fun add(a: Int, b: Int): Int
|
||||
}
|
||||
|
|
@ -8,10 +8,14 @@ import androidx.compose.foundation.isSystemInDarkTheme
|
|||
import androidx.compose.material3.*
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import net.mbess.popequer.AppContext
|
||||
import net.mbess.popequer.Native
|
||||
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Native.add(143, 54).let {
|
||||
println("From foreign rust result: $it")
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val appContext = AppContext(this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue