Skip to content

Commit bf88324

Browse files
authored
Merge branch 'main' into update-supporting-pane
2 parents 7a00b4f + 49323f3 commit bf88324

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager
18+
19+
import android.os.Bundle
20+
import android.util.Log
21+
import android.webkit.WebView
22+
import androidx.activity.ComponentActivity
23+
import androidx.activity.compose.setContent
24+
import androidx.compose.ui.viewinterop.AndroidView
25+
import androidx.webkit.WebSettingsCompat
26+
import androidx.webkit.WebViewFeature
27+
28+
// [START android_identity_webview_main_activity]
29+
class WebViewActivity : ComponentActivity() {
30+
override fun onCreate(savedInstanceState: Bundle?) {
31+
super.onCreate(savedInstanceState)
32+
setContent {
33+
// Put your webview link here.
34+
val url = "https://project-sesame-426206.appspot.com/passkey-signup"
35+
AndroidView(
36+
factory = { context ->
37+
WebView(context).apply {
38+
settings.javaScriptEnabled = true
39+
40+
webViewClient = WebViewClientImpl()
41+
}
42+
},
43+
update = { webView ->
44+
run {
45+
webView.loadUrl(url)
46+
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_AUTHENTICATION)) {
47+
WebSettingsCompat.setWebAuthenticationSupport(
48+
webView.settings,
49+
WebSettingsCompat.WEB_AUTHENTICATION_SUPPORT_FOR_APP,
50+
)
51+
// Check if getWebauthenticationSupport may have been disabled by the WebView.
52+
Log.e(
53+
"WebViewPasskeyDemo",
54+
"getWebAuthenticationSupport result: " + WebSettingsCompat.getWebAuthenticationSupport(
55+
webView.settings
56+
),
57+
)
58+
} else {
59+
Log.e("WebViewPasskeyDemo", "WebView does not support passkeys.")
60+
}
61+
}
62+
},
63+
)
64+
}
65+
}
66+
}
67+
// [END android_identity_webview_main_activity]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager
18+
19+
import android.webkit.WebView
20+
import android.webkit.WebViewClient
21+
22+
class WebViewClientImpl : WebViewClient() {
23+
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
24+
return false
25+
}
26+
}

0 commit comments

Comments
 (0)