如何使用Firebase Remote Config来实现此目的


每当

我需要使用 Google Firebase Remote 配置方法时,如何更改视频观看网址?

更多详细信息:我有一个使用 URL 显示视频或流的 VideoView,但我希望能够在需要时更改这些链接。无需创建新的应用程序更新!

我的活动:

package tk.protvapp.protv;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;
public class FoxActivity extends Activity {
    VideoView myVideoView;
    View v;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_fox);
        myVideoView = (VideoView)this.findViewById(R.id.videofox1); MediaController mc = new MediaController(this); myVideoView.setMediaController(mc);
        final String urlStream = "//Search the link in remote config for paste here";
        myVideoView.start();
        myVideoView.findFocus();
        runOnUiThread(new Runnable() { @Override public void run() { myVideoView.setVideoURI(Uri.parse(urlStream)); } });
    }
    public void voltarhomefox(View v){
        Intent intent = new Intent(FoxActivity.this, HomeActivity.class);
        startActivity(intent);
    }
}

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000"
    tools:context="tk.protvapp.protv.FoxActivity">

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="voltarhomefox"
        android:text="VOLTAR" />
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/button2"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:id="@+id/frameLayout">
        <VideoView
            android:id="@+id/videofox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
</RelativeLayout>

您可以在远程配置仪表板中定义密钥video_url = "https://foo.com/video.mp4"并使用 getString("video_url"( 方法从代码中获取video_url的值。

相关内容

最新更新