I'm using Autofill service in my app. But there are two problems with that:
- Presentation view is blinking while clicking on the username/passwords fields. Sometimes it appears but sometimes no.
- When I'm using setAuthentication method and returning the data set from my activity it doesn't work. It works for auto-filling in regular apps but doesn't work for webbrowsers.
I've already seen a lot of issues reported for chrome etc. but autofilling seems working correctly for example for the Bitwarden or Lastpass app.
This is my code in onFillRequest:
creating presentation:
val manualPresentation = createPresentation("Select password")
Creating data set:
val dataSet = Dataset.Builder()
.setValue(
passwordParsedAssistStructure.id,
AutofillValue.forText(null)
)
.setValue(
usernameParsedAssistStructure.id,
AutofillValue.forText(null)
)
val intent = Intent(applicationContext, AutofillActivity::class.java)
val sender = PendingIntent.getActivity(
applicationContext, id, intent,
PendingIntent.FLAG_CANCEL_CURRENT
).intentSender
val ids = arrayOf(passwordParsedAssistStructure.id, usernameParsedAssistStructure.id)
return FillResponse.Builder()
.addDataset(
dataSet.build()
)
.setAuthentication(ids, sender, manualPresentation)
.build()
also, I'm passing those ids into my activity and then return it:
val returnDataset = Dataset.Builder()
returnDataset.setValue(
passwordId,
AutofillValue.forText(String(password))
).setValue(
userId,
AutofillValue.forText(username)
)
val responseBuilder = FillResponse.Builder()
responseBuilder.addDataset(returnDataset.build())
val replyIntent = Intent().apply {
putExtra(EXTRA_AUTHENTICATION_RESULT, responseBuilder.build())
}
setResult(Activity.RESULT_OK, replyIntent)
finish()
What am I doing wrong? setAuthentication
method should be set on dataSet or fillResponse? Activity should return Dataset or FillResponse?
from setAuthentication method doesn't work with autofill
No comments:
Post a Comment