Skip to content

loading webview immediately after granting of permission #253

Open
@husaindevelop

Description

@husaindevelop

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions