android-studiohuawei-mobile-services

Huawei Safety Detect checkURL API threat return empty list even when using malicious url for testing


Im trying to check if url is malicious in my app. But the output always return that the link is safe even when i put malicious link. Im developing the app using Android Studio and use both GMS and HMS library. Im running the app on my device which is Samsung and its working fine except for the problem i mention above. Help me please. And one more thing, I've downloaded the appGallery on my phone and install hms core. But do i still need to convert gms library to hms library? Thank you.

This is the response code.

 @Override
                public void onSuccess(UrlCheckResponse urlCheckResponse) {
                    

                    List<UrlCheckThreat> list = urlCheckResponse.getUrlCheckResponse();
                    if (list.isEmpty()) {
                        // No threats found.
                        testRes.setText("No threats found.");
                    } else {
                        for (UrlCheckThreat threat : list){
                            int type = threat.getUrlCheckResult();

                            if(type == UrlCheckThreat.MALWARE){
                                //threat.getUrlCheckResult();
                                testRes.setText("Malware found!");
                            }
                            else {
                                if (type == UrlCheckThreat.PHISHING)
                                    //threat.getUrlCheckResult();
                                    testRes.setText("Phishing found!");
                            }
                        }

                    }

                }

Solution

  • Apparently, the API to check list of malicious URL took time to function. The response code was functioning well and can detect the malicious URL. Thank you for all the responses.