I want to launch the "Scan New Card" activity from my Android Application.
This functionality is provided by Google to scan and fill the credit/debit card number inside the EditText
and is the part of GMS Autofill Service.
My purpose is to provide a button to launch this intent, instead of using the existing option which shows up in the Autofill Popup/Ime Options.
I need to develop something like these screenshots from Google Play Store's Add Payment method and Google Autofill's Add Payment method.
Google Play Store's Add Payment method | Google Autofill's Add Payment method | Scan New Card IME option via Autofill |
---|---|---|
What I've tried:
I have tried the conventional way of adding the
autofillHint="creditCardNumber"
to theEditText
and thus showing the option to launch using the autofill service, however, if, for some reason, the Autofill service is disabled or not set to "Google" then this autofill option of "Scan New Card" doesn't show up.I have tried to launch the intent directly using the Activity and Package name I found from the
Logcat
, however aPermission Denied: Activity not exported
is thrown.
My Findings:
Logcat output when "Scan New Card" option provided by Google Autofill Service is clicked:
START u0 {act=SCAN_PAYMENT_CARD cmp=com.google.android.gms/.autofill.ui.AutofillActivity (has extras)} from uid 10102
START u0 {act=com.google.android.gms.ocr.ACTION_CREDIT_CARD_OCR pkg=com.google.android.gms cmp=com.google.android.gms/.ocr.SecuredCreditCardOcrActivity (has extras)} from uid 10102
Logcat output when launching the above intent directly using the Activity and Package name:
Permission Denial: starting Intent { act=SCAN_PAYMENT_CARD cmp=com.google.android.gms/.autofill.ui.AutofillActivity } from ProcessRecord{a45d996 13710:com.example.activity/u0a88} (pid=13710, uid=10088) not exported from uid 10013
FATAL EXCEPTION: main
Process: com.example.activity, PID: 13710
java.lang.SecurityException: Permission Denial: starting Intent { act=SCAN_PAYMENT_CARD cmp=com.google.android.gms/.autofill.ui.AutofillActivity } from ProcessRecord{a45d996 13710:com.example.activity/u0a88} (pid=13710, uid=10088) not exported from uid 10013
TLDR: I want to launch the following screen directly from a click of a button from my application instead of depending on the Google's Autofill Service.