deptofdefense / AndroidTacticalAssaultKit-CIV

Other
32 stars 14 forks source link

WebView Support #245

Open glenngartner opened 2 years ago

glenngartner commented 2 years ago

Anyone have success using WebView in an ATAK plugin? I've added a simple WebView component, and when I launch the plugin, ATAK crashes. No discernable errors from LogCat

2022-08-18 10:17:15.526 1647-1678/system_process I/WifiService: requestActivityInfo uid=1000
2022-08-18 10:17:15.526 1647-1678/system_process I/WifiService: reportActivityInfo uid=1000
2022-08-18 10:17:15.526 1647-1678/system_process I/WifiService: getSupportedFeatures uid=1000
2022-08-18 10:17:15.811 8386-8485/com.atakmap.app.civ D/Dt2FileWatcher: Took 1ms to scan DTED directory for 4 files.
2022-08-18 10:17:16.400 2067-9348/com.google.android.gms.persistent E/memtrack: Couldn't load memtrack module
2022-08-18 10:17:16.400 2067-9348/com.google.android.gms.persistent W/android.os.Debug: failed to get memory consumption info: -1
2022-08-18 10:17:20.033 2275-9349/com.google.android.gms E/memtrack: Couldn't load memtrack module
2022-08-18 10:17:20.034 2275-9349/com.google.android.gms W/android.os.Debug: failed to get memory consumption info: -1
2022-08-18 10:17:22.527 1449-1449/? I/boot-pipe: done populating /dev/random
2022-08-18 10:17:24.146 3789-9352/com.google.android.gms.unstable E/memtrack: Couldn't load memtrack module
2022-08-18 10:17:24.146 3789-9352/com.google.android.gms.unstable W/android.os.Debug: failed to get memory consumption info: -1

The WebView component:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="3dp"
    android:layout_marginRight="3dp"
    android:fadeScrollbars="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_name" />

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
</ScrollView>

Per Google's recommendation, I've loaded the androidx.webkit library for older versions of android

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    implementation "androidx.core:core-ktx:+"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.webkit:webkit:1.4.0"
}
bisgroves commented 1 year ago

You need to programatically create the WebView and add it to the layout.