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

loading webview immediately after granting of permission #253

Open
husaindevelop opened this issue Jun 28, 2022 · 1 comment
Open

loading webview immediately after granting of permission #253

husaindevelop opened this issue Jun 28, 2022 · 1 comment
Labels

Comments

@husaindevelop
Copy link

In our android webview app, We ask for read_contacts, location, camera, audio permissions at a time on initialization of app. What happens is that simultaneously the webview url is also loaded. This causes some data like contacts json object not to be passed to webview in the first load.

What we expect from the app is to load the webview url immediately after user allows, grants permissions for the above only and not before that. We tried using onRequestPermissionsResult for achieving this, but unable to do so. The code we have tried is as given hereunder:

@Override
	public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
		if (requestCode == 1) {
			// Use this method to check if all the permissions are GRANTED.
			if (areAllPermissionsGranted(grantResults)) {
				get_location();


			}
		}
	}

	// Method to check if all the results are GRANTED.
	private Boolean areAllPermissionsGranted(int[] grantResults) {
		boolean isGranted = false;
		if (grantResults.length > 0) {
			for (int grantResult : grantResults) {
				if (grantResult == PackageManager.PERMISSION_GRANTED) {
					isGranted = true;
					aswm_view(ASWV_URL, false, asw_error_counter);
				} else {
					// if a single permission is NOT_GRANTED, return from the method.
					return false;
				}
			}
		}
		return isGranted;
	}
	

Shall appreciate should you help us out on this issue.

@mgks
Copy link
Owner

mgks commented Oct 6, 2022

we already have a function called check_permission where you can put individual request code and create a simple condition to whether load the webview URL or do something of your own.

@mgks mgks added the help label Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants