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 the EditText 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 a Permission 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.
Related
I want to open settings screen from my app.
I have made app exported = true in Manifest
Besides that I made sure that I pick correct configuration app while running
from this post -> Android - java.lang.SecurityException: Permission Denial: starting Intent
But still got this error
java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.settings/.SubSettings } from ProcessRecord{a973751 21451:com.myapp.android.main/u0a157} (pid=21451, uid=10157) not exported from uid 1000
My code of launching the activity is
val intentTwo = Intent()
intentTwo.setClassName("com.android.settings",
"com.android.settings.SubSettings")
startActivity(intentTwo)
I have also tried this one
val intentOne = Intent()
intentOne.setComponent(ComponentName("com.android.settings",
"com.android.settings.SubSettings"))
startActivity(intentOne)
Any ideas on that?
SubSettings is not exported from the Settings app, at least for AOSP and Android 13. For any device configured this way, you cannot start this activity.
Also, please bear in mind that the system Settings app frequently gets modified by device manufacturers. As a result, there is no requirement for any device to even have SubSettings, let alone have it available to be started by external apps.
And, note that SubSettings does not seem to do much.
I got this error when I try to launch the details screen.
IActivityManagerProxy : Instant app: com.foo.bar crashed: java.lang.SecurityException: Not allowed to start activity Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS dat=package:com.foo.bar }
Is there any work around to launch details on instant app?
You're trying to access settings. This is intentionally not available to instant apps for security reasons.
A workaround would be to ask the user to manually go to the settings in case your app is running in the instant app context.
I follow the android documentation to write an application with search widget.
But I found that two ACTION_SEARCH intents are sent to the SearchActivity. So, I doubt that is that my fault.
And then I try the Google Play app. I enter keyword to search app and I still capture two intents! Here is the logcat. So, how should be handle this? Even I override onNewIntent with singleTop Activity, it need to search twice to handle one search operation!
04-18 22:26:19.007: I/ActivityManager(389): START u0
{act=android.intent.action.SEARCH flg=0x10000000
cmp=com.android.vending/.AssetBrowserActivity (has extras)} from pid
1721 04-18 22:26:19.007: I/ActivityManager(389): START u0
{act=android.intent.action.SEARCH flg=0x10000000
cmp=com.android.vending/.AssetBrowserActivity (has extras)} from pid
1721
This is a bug in the emulator when using the hardware keyboard.
http://books.google.com/books?id=OFXJXbCXjTgC&pg=PT771&lpg=PT771&dq=android+search+intent+sent+twice+bug&source=bl&ots=Ora1AJjh4A&sig=9yFBjCwJ1ARbXePHzcPYpG_QdFQ&hl=en&sa=X&ei=bbddUpbZCcLi4AOiioCIAw&ved=0CD8Q6AEwAw#v=onepage&q=android%20search%20intent%20sent%20twice%20bug&f=false
You can disable the hardware keyboard in the emulator by going to Settings -> Language & input and selecting Default.
When using the soft keyboard in the emulator I only get one intent.
I have a live Wallpaper. This live wallpaper has a settings page implemented from PreferenceActivity. Everything works as expected. So far, so good.
From my Wallpaper Settings page..I want to start another activity (a details activity...with info, bitmaps, links, etc...). When I start this activity I get a security exception error:
java.lang.SecurityException: Permission Denial: starting Intent {... } from ProcessRecord ... requires android.permission.BIND_WALLPAPER
The manifest has the required permission. I've tried putting this permission everywhere .. even in multiple locations (not just in the service tag in the manifest). I'm starting the Activity from the wallpaper settings page with a new intent, then calling startActivity.
Does anyone know why I'm getting the permission denial even when the permission is included? Can someone tell me how to start the activity correctly without getting a force close?
Much appreciated.
Logcat prints 05-09 08:26:17.979 I/ActivityManager( 2257): Starting activity: Intent { cmp=com
.com.pkg/.classname (has extras) }
How to know what are those extra key pair values?
The above log comes from a third party app which i don't have any control.
How to know what are those extra key pair values?
Call getExtras() to get the Bundle, then call keySet() to see all of the keys.
The above log comes from a third party app which i don't have any control.
Or, ask the developers of the app that is launching you what they are putting in as extras. Usually it is up to the recipient to document what extras are expected, except for standard actions (e.g., ACTION_SEND).