[Huawei Developers] Freemind R:
It can be difficult for users to differentiate between legitimate URLs and malicious ones which attempt to trick them into transferring money or sharing personal details. To address this issue, HUAWEI Safety Detect provides a malicious URL check function (URLCheck) which helps developers identify the threats posed by malicious URLs.

I. Service Introduction

URLCheck's malicious URL check capability is reliable, easy to integrate, and free of maintenance. With this capability, creating a secure browsing service has never been cheaper or simpler.

Once you have integrated URLCheck into your app, the process of checking URLs is as follows.

(1) Your app has the Safety Detect SDK integrated and calls the URLCheck API.

(2) Safety Detect requests a URL check from the URLCheck server, and then sends back the check result to your app (normal URL, phishing URL, or malicious software URL).

(3) Your app can determine whether to access the URL based on the check result.

II. Scenarios

Developers in many industries have integrated URLCheck to identify risks posed by URLs accessed within their apps. This enables them to determine whether to block risky URLs based on the check result.

l URLCheck can help the app check whether the URL the user wants to access is secure, and determine whether to access the URL based on the check result.

l If the URL is risky, the app will show a security warning before enabling the user to access the URL.

III. Code Development

1 Configure app information in AppGallery Connect.

Before you start developing an app, configure app information in AppGallery Connect.

For more details about how to do this, take a look at our website.

2 Configure the Maven repository address for the HMS Core SDK.

2.1 Open the build.gradle file in the root directory of your Android Studio project.

2.2 Add the AppGallery Connect plug-in and the Maven repository.

· Go to allprojects > repositories and configure the Maven repository address for the HMS Core SDK.

1. allprojects {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}

Go to buildscript > repositories and configure the Maven repository address for the HMS Core SDK.

1. buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}

Go to buildscript > dependencies and add dependency on the AppGallery Connect plug-in.

buildscript{
dependencies {
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
}
}

3 Add build dependencies in the dependencies section.

// Create a SafetyDetectClient instance.
SafetyDetectClient mClient = SafetyDetect.getClient(MainActivity.this);

4.1 Initialize URLCheck.

// Initialize URLCheck.
mClient.initUrlCheck();

4.2 Request a URL check.

client.urlCheck(url, appid, UrlCheckThreat.MALWARE)
.addOnSuccessListener(new OnSuccessListener<UrlCheckResponse>() {
@Override
public void onSuccess(UrlCheckResponse urlCheckerResponse) {
List<UrlCheckThreat> list = urlCheckerResponse.getUrlCheckResponse();
if (list.isEmpty()) {
// No threats detected.
} else {
// Threats detected.
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException){
ApiException apiException = (ApiException) e;
} else {
// An unknown error occurred.
}
}
});

4.3 Shut down URLCheck.

// Shut down URLCheck.
mClient.shutdownUrlCheck();

Demo

URLCheck on HUAWEI Developers

Safety Detect Development Guide

Sample Code on GitHub

Stack Overflow (where you can ask more questions)