我想从我的 Android 应用程序启动“扫描新卡”活动。此功能由 Google 提供,用于扫描并填写信用卡/借记卡号,EditText是 GMS 自动填充服务的一部分。
我的目的是提供一个按钮来启动此意图,而不是使用自动填充弹出窗口/Ime 选项中显示的现有选项。
我需要开发类似 Google Play 商店的添加付款方式和 Google 自动填充的添加付款方式的屏幕截图的内容。
我尝试过的:
我已尝试使用传统方法添加autofillHint="creditCardNumber",EditText从而显示使用自动填充服务启动的选项,但是,如果由于某种原因自动填充服务被禁用或未设置为“Google”,则“扫描”的自动填充选项新卡”没有出现。
我尝试使用从 中找到的活动和包名称直接启动意图Logcat,但是Permission Denied: Activity not exported抛出了 a 。
我的发现:
单击 Google 自动填充服务提供的“扫描新卡”选项时的 Logcat 输出:
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
Run Code Online (Sandbox Code Playgroud)
直接使用 Activity 和 Package 名称启动上述 Intent 时的 Logcat 输出:
Permission Denial: starting …Run Code Online (Sandbox Code Playgroud) 我有一个 BottomNavigationView 并且想要为选定和未选定状态使用自定义图标。尝试使用选择器但它不起作用。
知道如何放置自定义图标吗?
编辑- 将评论中的代码添加到问题中
<item
android:id="@+id/navigation_card"
android:icon="@drawable/iv_home_card"
app:itemBackground="@drawable/navigation_card"
app:showAsAction="ifRoom" tools:ignore="MenuTitle"
/>
Run Code Online (Sandbox Code Playgroud)
像这样我添加了图标。现在对于选定状态,它用主题颜色描边,但我想用另一个图标替换图标。
我尝试制作选择器但没有用
<selector
xmlns:android="schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/btn_star_off_normal" />
<item android:state_checked="true"
android:drawable="@drawable/btn_star_on_normal" />
</selector>
Run Code Online (Sandbox Code Playgroud)
BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) { }
return false;
}
};
Run Code Online (Sandbox Code Playgroud) android android-layout bottomnavigationview android-bottomnav