我正在尝试使用 DataSet.Builder 方法为我的填充响应创建一个自动填充服务。我想不出一种将 AutofillId 传递给该数据集的方法。
val context = request.fillContexts.last()
//creates a parser to parse the view
val parser = AssistStructureParser(context.structure)// Add a dataset to the response
val fillResponse: FillResponse = FillResponse.Builder()
.addDataset(Dataset.Builder()
.setValue(
//Pass some autofillID signifying the UN field,
AutofillId(parser.fieldIds[AutofillInputType.UserName].hashCode()),
AutofillValue.forText("username")
//usernamePresentation
)
.setValue(
//Pass some autofillID signifying the PW field,
AutofillId(parser.fieldIds[AutofillInputType.Password].hashCode()),
AutofillValue.forText("password")
//passwordPresentation
)
.build())
.build()
就像现在一样,我受到了打击
e: autofill_service\FlutterMyAutofillService.kt: (239, 33): Cannot access '<init>': it is public/*package*/ in 'AutofillId'
e: autofill_service\FlutterMyAutofillService.kt: (245, 33): Cannot access '<init>': it is public/*package*/ in 'AutofillId'
我只需要弄清楚如何传递一个 autofillId 对象。
以供参考,
var usernamefields = parser.fieldIds[AutofillInputType.UserName]
Log.d("USERNAME FIELDS", "${usernamefields}")
[MatchedField(heuristic=AutofillHeuristic(weight=700, predicate=Function2<android.app.assist.AssistStructure$ViewNode,
android.app.assist.AssistStructure$ViewNode, java.lang.Boolean>), autofillId=1073741824@1381197270), MatchedField(heuristic=Autofi
llHeuristic(weight=700, predicate=Function2<android.app.assist.AssistStructure$ViewNode, android.app.assist.AssistStructure$ViewNode, java.lang.B
oolean>), autofillId=1073741828@1381197270)]