view android/DWindows.kt @ 2474:a13e6db064f4

Android: Implement thread, semaphore, shared memory API functions. Implement dwmain() entrypoint and include dwtest.c in the build. Like on iOS dw_main() doesn't actually run the message loop... So wait for dw_main() to be called and return to the JVM.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 19 Apr 2021 23:06:25 +0000
parents aa420e366b2b
children 16d195d46f2a
line wrap: on
line source

package org.dbsoft.dwindows.dwtest

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity


class DWindows : AppCompatActivity()
{
    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dwindows_main)

        val m = packageManager
        var s = packageName
        val p = m.getPackageInfo(s!!, 0)
        s = p.applicationInfo.dataDir

        // Example of a call to a native method
        findViewById<TextView>(R.id.sample_text).text = dwindowsInit(s)
    }

    /**
     * Native methods that are implemented by the 'dwindows' native library,
     * which is packaged with this application.
     */
    external fun dwindowsInit(dataDir: String): String

    companion object
    {
        // Used to load the 'dwindows' library on application startup.
        init
        {
            System.loadLibrary("dwindows")
        }
    }
}