Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview in background using service but location not working #270

Open
olyjosh opened this issue Aug 23, 2020 · 0 comments
Open

Webview in background using service but location not working #270

olyjosh opened this issue Aug 23, 2020 · 0 comments

Comments

@olyjosh
Copy link

olyjosh commented Aug 23, 2020

I was trying to make the webview send geo-location in in background with this code I have below. No luck so far but thesame code works fine in activity
`

	mWebView = new WebView(getApplicationContext());
	//mWebView.setListener(this, this);
            mWebView.setListener(new Activity(), this);
	mWebView.setGeolocationEnabled(true);
	mWebView.setMixedContentAllowed(true);
	mWebView.setCookiesEnabled(true);
	mWebView.setThirdPartyCookiesEnabled(true);
	mWebView.setWebViewClient(new WebViewClient() {


		/*
		@Override
		public void onPageFinished(WebView view, String url) {
		//	Toast.makeText(MainActivity.this, "Finished loading", Toast.LENGTH_SHORT).show();

		}*/

	});
	mWebView.setWebChromeClient(new WebChromeClient() {

		@Override
		public void onReceivedTitle(WebView view, String title) {
			super.onReceivedTitle(view, title);
			Toast.makeText(MainActivity.this, title, Toast.LENGTH_SHORT).show();
		}

	});

	mWebView.addHttpHeader("X-Requested-With", "");
	mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
	mWebView.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
	mWebView.setWebViewClient(new MyWebViewClient());
	mWebView.getSettings().setJavaScriptEnabled(true);




	mWebView.loadUrl(TEST_PAGE_URL);

`

Please help or positive director will be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant