CardEmulation.SetPreferredService(Activity, ComponentName) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allows a foreground application to specify which card emulation service should be preferred while a specific Activity is in the foreground.
[Android.Runtime.Register("setPreferredService", "(Landroid/app/Activity;Landroid/content/ComponentName;)Z", "")]
public bool SetPreferredService (Android.App.Activity? activity, Android.Content.ComponentName? service);
[<Android.Runtime.Register("setPreferredService", "(Landroid/app/Activity;Landroid/content/ComponentName;)Z", "")>]
member this.SetPreferredService : Android.App.Activity * Android.Content.ComponentName -> bool
Parameters
- activity
- Activity
The activity which prefers this service to be invoked
- service
- ComponentName
The service to be preferred while this activity is in the foreground
Returns
whether the registration was successful
- Attributes
Remarks
Allows a foreground application to specify which card emulation service should be preferred while a specific Activity is in the foreground.
The specified Activity must currently be in resumed state. A good paradigm is to call this method in your Activity#onResume
, and to call #unsetPreferredService(Activity)
in your Activity#onPause
.
This method call will fail in two specific scenarios: <ul> <li> If the service registers one or more AIDs in the #CATEGORY_PAYMENT
category, but the user has indicated that foreground apps are not allowed to override the default payment service. <li> If the service registers one or more AIDs in the #CATEGORY_OTHER
category that are also handled by the default payment service, and the user has indicated that foreground apps are not allowed to override the default payment service. </ul>
Use #categoryAllowsForegroundPreference(String)
to determine whether foreground apps can override the default payment service.
Note that this preference is not persisted by the OS, and hence must be called every time the Activity is resumed.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.