小编And*_*rew的帖子

在构建版本中未找到数据类 Kotlin 的序列化器

我想将 json 字符串响应从 API 转换为对象:

val obj = Json.decodeFromString<MyModel>(jsonResponseString)
Run Code Online (Sandbox Code Playgroud)

我的数据类:

@Serializable
data class MyModel(
    @SerializedName("field") val field: String
)
Run Code Online (Sandbox Code Playgroud)

它看起来非常简单,并且可以在调试模式下运行!

但是,当编译 AppBundle、以发布模式构建并从 Play Store 内部测试下载应用程序时,我收到以下错误:

Serializer for class '...' is not found. Mark the class as @serializable or provide the 
serializer explicitly.
kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered
Run Code Online (Sandbox Code Playgroud)

android serializable kotlin kotlinx.serialization

11
推荐指数
2
解决办法
7069
查看次数

如何获得Facebook的所有字段Api-Graph v2.8

我想尝试看起来像这样的东西:

GET/v2.8/PageFacebook/posts?fields="all??"
Run Code Online (Sandbox Code Playgroud)

这是因为默认情况下它不会给我发布帖子的"名称"或"类型".而且我不想进行逐场咨询.

api facebook facebook-graph-api

5
推荐指数
1
解决办法
5208
查看次数

如何在 Android Web View 中嵌入 iframe 视频?

我想将以下视频嵌入到 Android Web 视图中: https://www.espn.com.ar/core/video/iframe ?id=6034792&endcard=false&omniReportSuite=wdgespg

我尝试了不同的网络视图方法,但没有任何结果。没有错误,我只能查看播放器,但无法播放。

在此输入图像描述

//显现:

<uses-permission android:name="android.permission.INTERNET" />

<application
... 
android:hardwareAccelerated="true">
Run Code Online (Sandbox Code Playgroud)

//代码:

String html = String.format("<iframe src=\"%s\" width=\"340\" height=\"313\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>", url.getSrc());
wview.loadDataWithBaseURL("https://www.espn.com.ar", html, "text/html", "UTF-8", null);

//OR

wview.loadUrl(url.getSrc());

//MY WEBVIEW:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:wheel="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true">

        <WebView
            android:id="@+id/wview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

embed video android webview android-webview

2
推荐指数
1
解决办法
4519
查看次数

向 Kotlin 改造调用发送参数

我是 Kotlin 的初学者。我需要将一个可变参数从我的 Activity 发送到 Retrofit 调用。

这是我对创建细节活动的呼吁

override fun onCreate(savedInstanceState: Bundle?) {
    //...
    val id = intent.getStringExtra("id")

    // Get the ViewMode
    val mModel = ViewModelProviders.of(this).get(myObjectViewModel::class.java)

    //Create the observer which updates the UI.
    val myObjectByIdObserver = Observer<MyObject> { myObject->
        //...
    }

    //Observe the LiveData, passing in this activity as the LifecycleOwner and the observer.
    mModel.getObjectById.observe(this, myObjectByIdObserver)
}
Run Code Online (Sandbox Code Playgroud)

这里我插入值硬编码,我需要从上一个活动接收到的参数。

class MyObjectViewModel : ViewModel() {

    //this is the data that we will fetch asynchronously 
    var myObject: MutableLiveData<MyObject>? = null

    val getMyObjectById: LiveData<MyObject> …
Run Code Online (Sandbox Code Playgroud)

android observable kotlin retrofit android-livedata

1
推荐指数
1
解决办法
6466
查看次数