Skip to content

Instantly share code, notes, and snippets.

@geek-atif
Created September 23, 2023 13:46
Show Gist options
  • Save geek-atif/07ea5e32fec058c1546410fa500227a4 to your computer and use it in GitHub Desktop.
Save geek-atif/07ea5e32fec058c1546410fa500227a4 to your computer and use it in GitHub Desktop.
package com.atifqamar.helloworldndk
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.atifqamar.helloworldndk.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
//call to a native method
binding.sampleText.text = helloWorld()
}
/**
* A native method that is implemented by the 'helloworldndk' native library,
* which is packaged with this application.
*/
external fun helloWorld(): String
companion object {
// Used to load the 'helloworldndk' library on application startup.
init {
System.loadLibrary("helloworldndk")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment