日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android ndk webview,Android 集成 X5 WebView

發布時間:2023/12/31 Android 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android ndk webview,Android 集成 X5 WebView 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

AndroidManifest.xml

1.添加jar包

在libs目錄下添加sdk中的jar包

將Demo中的jniLibs目錄復制到 main文件夾下

2.需要添加權限

3.build.gradle 添加配置

ndk {

abiFilters "armeabi", "armeabi-v7a", "x86", "mips"

}

4.頁面

android:id="@+id/web_view"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:paddingLeft="5dp"

android:paddingRight="5dp" />

5.Activity

package com.sykj.article.articlesystem;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import com.tencent.smtt.sdk.QbSdk;

import com.tencent.smtt.sdk.WebView;

import com.tencent.smtt.sdk.WebViewClient;

public class MainActivity extends AppCompatActivity {

private WebView webView;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.web_view);

initX5WebView();

webView = findViewById(R.id.web_view);

//防止跳轉到系統瀏覽器

webView.setWebViewClient(new WebViewClient() {

@Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

loadurlLocalMethod(view, url);

return false;

}

});

webView.loadUrl("http://www.baidu.com");

}

public void loadurlLocalMethod(final WebView webView, final String url) {

new Thread(new Runnable() {

@Override

public void run() {

webView.loadUrl(url);

}

});

}

private void initX5WebView() {

//搜集本地tbs內核信息并上報服務器,服務器返回結果決定使用哪個內核。

QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

@Override

public void onViewInitFinished(boolean arg0) {

if (arg0) {

Log.d("ArticleSystem", "X5 內核加載成功");

} else {

Log.d("ArticleSystem", "X5 內核加載失敗");

}

}

@Override

public void onCoreInitFinished() {

}

};

//x5內核初始化接口

QbSdk.initX5Environment(getApplicationContext(), cb);

}

}

完整配置

AndroidManifest.xml

package="com.sykj.article.articlesystem">

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_round"

android:supportsRtl="true"

android:theme="@style/AppTheme">

web_view.xml

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

android:id="@+id/web_view"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:paddingLeft="5dp"

android:paddingRight="5dp" />

build.gradle

apply plugin: 'com.android.application'

android {

compileSdkVersion 27

defaultConfig {

applicationId "com.sykj.article.articlesystem"

minSdkVersion 15

targetSdkVersion 27

versionCode 1

versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

ndk {

abiFilters "armeabi", "armeabi-v7a", "x86", "mips"

}

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation 'com.android.support:appcompat-v7:27.1.1'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.2'

androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation files('libs/tbs_sdk_thirdapp_v3.6.0.1352_43618_sharewithdownload_withoutGame_obfs_20180918_120327.jar')

}

總結

以上是生活随笔為你收集整理的android ndk webview,Android 集成 X5 WebView的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。