Mercurial > dwindows
diff android/DWindows.kt @ 2694:cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 02 Nov 2021 19:04:56 +0000 |
parents | 231f9489a38a |
children | 9df2c11f020f |
line wrap: on
line diff
--- a/android/DWindows.kt Mon Nov 01 01:32:42 2021 +0000 +++ b/android/DWindows.kt Tue Nov 02 19:04:56 2021 +0000 @@ -62,6 +62,10 @@ import java.util.concurrent.locks.ReentrantLock import java.util.zip.ZipEntry import java.util.zip.ZipFile +import android.content.Intent + + + object DWEvent { const val TIMER = 0 @@ -1024,6 +1028,21 @@ return darkMode } + fun browseURL(url: String): Int { + var retval: Int = -1 // DW_ERROR_UNKNOWN + + waitOnUiThread { + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + try { + retval = 0 // DW_ERROR_NONE + startActivity(browserIntent) + } catch (e: ActivityNotFoundException) { + retval = -1 // DW_ERROR_UNKNOWN + } + } + return retval + } + fun menuPopup(menu: DWMenu, parent: View, x: Int, y: Int) { var anchor: View? = parent