Appium Android Hybrid app doesn't give handle to Current Active URL

Hi,

I have a program where i have to Automate the Hybrid App but after some page navigation on hybrid Pages there are Multiple URLs in Window handles like around 4-5 or some time more than 10, out of which only 1 is Active and others are empty and hidden URLs as per -“chrome://inspect/devices#devices” .
I have to handle and work on Active URL.

https://dummyURL.dummyURL.in/2.0/dist/consent-new/consentPopup - empty
https://www.dummyURL.in/home-loan-interest-rates - Active
https://dummyURL.dummyURL.in/2.0/dist/search/content - hidden
file:///android/phare/index.html - hidden

here is my Code where i have assumed to handle that but in descending order its getting the active but at 1 stage i stucked and it returned me empty as the last url which is not correct URL. I want the active URL which is displayed on the Android App

public void cfnHandleActiveWebTab() throws InterruptedException {
	Thread.sleep(2000);
	Set<String> windowHandles = driver.getWindowHandles();
	List<String> handlesList = new ArrayList<>(windowHandles);
	Collections.reverse(handlesList);

	boolean foundWebURL = false;
	for (String handle : handlesList) {
		driver.switchTo().window(handle);
		String currentURL = driver.getCurrentUrl();
		System.out.println(currentURL);
	}
	for (String handle : handlesList) {
		driver.switchTo().window(handle);
		String currentURL = driver.getCurrentUrl();
		boolean isWebURL = currentURL.startsWith("http");
		if (isWebURL) {
			logger.info("Final Page URL: " + currentURL);
			foundWebURL = true;
			break;
		}
	}

	if (!foundWebURL) {
		logger.info("No valid web URL found in window handles.");
	}
}

Please Help me this

Try https://github.com/appium/appium-uiautomator2-driver#mobile-getcontexts endpoint. It should be easier to filter its output in order to find the right view

Can you give any example as i am not getting how to implement the same and how it will handle my purpose. Hope it gives what i am looking for.