Repository: NativeScript/NativeScript
File: packages/core/ui/web-view/index.android.ts (TypeScript)

Code before:
	@NativeClass
	class WebViewClientImpl extends android.webkit.WebViewClient {
		constructor(public owner: WebViewBase) {
			super();

			return global.__native(this);
		}

		public shouldOverrideUrlLoading(view: android.webkit.WebView, target: any) {
			const url: string = target instanceof android.webkit.WebResourceRequest ? target.getUrl().toString() : target;

			if (Trace.isEnabled()) {
				Trace.write('WebViewClientClass.shouldOverrideUrlLoading(' + url + ')', Trace.categories.Debug);
			}

			if (android.webkit.URLUtil.isNetworkUrl(url)) {
				return false;
			}

			// Handle schemes like mailto, tel, etc
			// Make sure to add  <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>  to AndroidManifest.xml
			// We check if there is any app installed on the device to handle the special URL(mailto, tel, etc)
			const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
			intent.setData(android.net.Uri.parse(url));

			const packageManager = application.android.context.getPackageManager();
			if (intent.resolveActivity(packageManager) != null) {
				// App exists to handle the URL. So, open the app
				openUrl(url);
				return true;
			}

			return false;
		}

		public onPageStarted(view: android.webkit.WebView, url: string, favicon: android.graphics.Bitmap) {
			super.onPageStarted(view, url, favicon);
			const owner = this.owner;
			if (owner) {
				if (Trace.isEnabled()) {
					Trace.write('WebViewClientClass.onPageStarted(' + url + ', ' + favicon + ')', Trace.categories.Debug);
				}
				owner._onLoadStarted(url, undefined);
			}
		}

		public onPageFinished(view: android.webkit.WebView, url: string) {
			super.onPageFinished(view, url);
			const owner = this.owner;
			if (owner) {
				if (Trace.isEnabled()) {

Review comment (suggestion):
Then you can use it here:
```
const packageManager = ad.getApplicationContext().getPackageManager();
```

This will properly avoid the import of `application` in this file.

Code after:
	class WebViewClientImpl extends android.webkit.WebViewClient {
		constructor(public owner: WebViewBase) {
			super();

			return global.__native(this);
		}

		public shouldOverrideUrlLoading(view: android.webkit.WebView, target: any) {
			const url: string = target instanceof android.webkit.WebResourceRequest ? target.getUrl().toString() : target;

			if (Trace.isEnabled()) {
				Trace.write('WebViewClientClass.shouldOverrideUrlLoading(' + url + ')', Trace.categories.Debug);
			}

			// Handle schemes like mailto, tel, etc
			if (!android.webkit.URLUtil.isNetworkUrl(url)) {
				return openUrl(url);
			}

			return false;
		}

		public onPageStarted(view: android.webkit.WebView, url: string, favicon: android.graphics.Bitmap) {
			super.onPageStarted(view, url, favicon);
			const owner = this.owner;
			if (owner) {
				if (Trace.isEnabled()) {
					Trace.write('WebViewClientClass.onPageStarted(' + url + ', ' + favicon + ')', Trace.categories.Debug);
				}
				owner._onLoadStarted(url, undefined);
			}
		}

		public onPageFinished(view: android.webkit.WebView, url: string) {
			super.onPageFinished(view, url);
			const owner = this.owner;
			if (owner) {
				if (Trace.isEnabled()) {
					Trace.write('WebViewClientClass.onPageFinished(' + url + ')', Trace.categories.Debug);
				}
				owner._onLoadFinished(url, undefined);
			}
		}

		public onReceivedError(...args) {
			const view: android.webkit.WebView = args[0];

			if (arguments.length === 4) {
				const errorCode: number = args[1];
				const description: string = args[2];
				const failingUrl: string = args[3];