Polyv Help Center

Help Center

Android

Updated: 2026-05-20 17:22:50

1 Preparation

Download the project demo in advance and prepare a URL, preferably a viewing URL for Polyv Cloud Live or Cloud Video, to experience the full functionality.

2 Environment Requirements

Name Requirement
Android System 4.2+
JDK 1.7+
Android Studio 3.0.0+

3 Project Configuration

3.1 Configure Supported System Version

Open the build.gradle file of the project module and change minSdkVersion to 17 or higher.

3.2 Configure Manifest

Open the AndroidManifest.xml file of the project module and add the following content:

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
  <!--网络权限-->
    <uses-permission android:name="android.permission.INTERNET" />
  <!--悬浮小窗-从后台快速恢复到前台-->
    <uses-permission android:name="android.permission.REORDER_TASKS" />
  <!--悬浮小窗-悬浮窗权限-->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <!--网络状态权限-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!--连麦权限-->
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
  
  <!--Android 9及以上系统默认应用禁止Http明文访问,如需要加载http内容,请声明usesCleartextTraffic=true -->
    <application
        ...
        android:usesCleartextTraffic="true"
        android:hardwareAccelerated="true"
        ...>
        ...
    </application>
</manifest>

3.3 Configure Maven

Open the build.gradle file in the project root directory and add the following content:

allprojects {
    repositories {
        google()
        jcenter()
        //添加jitpack仓库
        maven { url "https://jitpack.io" }
        //保利威阿里云效
        maven {
            credentials {
                username '609cc5623a10edbf36da9615'
                password 'EbkbzTNHRJ=P'
            }
            url 'https://packages.aliyun.com/maven/repository/2102846-release-8EVsoM/'
        }
    }
}

4 Integrate SDK

In the build.gradle file of the project module, add the following content:

api 'net.polyv.android:webView:3.2.0' // 3.2.0为具体的SDK版本号

5 Code Invocation

Use PLVWebViewConfig to set the URL and UA to be loaded, then pass PLVWebViewConfig to PLVWebViewDemoActivity to load the corresponding web page. Example code is as follows:

PLVWebViewConfig config = new PLVWebViewConfig();
config.setUrl("需要加载的url")
        .setUa("需要添加的UA");
PLVWebViewDemoActivity.startWebViewDemoActivity(PLVURLInputActivity.this, config);

Currently, in PLVWebViewBaseActivity, functionalities such as WebView management and picture-in-picture are already implemented. Simply create a new Activity that inherits from PLVWebViewBaseActivity to complete the integration.

public class PLVWebViewDemoActivity extends PLVWebViewBaseActivity {
    
      public static void startWebViewDemoActivity(Activity activity, PLVWebViewConfig config) {
        Intent intent = new Intent(activity, PLVWebViewDemoActivity.class);
        intent.putExtra(PLV_WEB_VIEW_STATUS_CONFIG, config);
        activity.startActivity(intent);
    }
}
注意:Activity的启动模式需要选择singleTask
联系客服,在线咨询
在线咨询