AdBlock in WebView cu Android Studio

DaVinci

-
Registered
Full Member
Buna ziua, vreau sa creez o aplicatie de android cu android studio si as dorii sa integrez adblock in aplciatie

activity_main.xml
Cod:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context="com.webviewapp.MainActivity">
 
    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
 
</RelativeLayout>
MainActivity.java
Cod:
package com.webviewapp;
 
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
 
public class MainActivity extends AppCompatActivity {
    private WebView webView;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        webView = (WebView) findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("http://www.google.com");
 
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
    }
 
    @Override
    public void onBackPressed() {
        if (webView.canGoBack()) {
            webView.goBack();
        } else {
            super.onBackPressed();
        }
    }
}
AndroidManifest.xml
Cod:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.webviewapp">
 
    <uses-permission android:name="android.permission.INTERNET" />
 
    <application
        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">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
 
</manifest>
Acesta este sursa aplicatiei, i-ar mai jos am gasit cum se face dar nu ma pricep (nu inteleg nimic), ma poate ajuta cineva?

Cod:
https://github.com/AmniX/AdBlockedWebView-Android
sau
https://github.com/adblockplus/libadblockplus-android
 

Reclama

Topicuri Recomandate

  1. Platforma CPL Romania

Stiri Monezi Virtuale

Reducere pentru Vacanta

Sunt Invizibil

Loading...
Sus